473,325 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Displaying only selected columns in a data grid?

Have an Access table loaded into a DataTable that was created at run time,
and am displaying these contents in a data grid.
Me.dgGames.DataSource = Me.DsGameInfo.Tables("Games")

I would like to display only a selected few of the columns, rather than the
whole table.
Is this possible?
Thanks - Sean
Nov 20 '05 #1
7 14628
"What-a-Tool" <Fr***********************@cox.net> wrote in
news:mSMcb.15428$0Z5.1761@lakeread03:
Have an Access table loaded into a DataTable that was created at run
time, and am displaying these contents in a data grid.
Me.dgGames.DataSource = Me.DsGameInfo.Tables("Games")

I would like to display only a selected few of the columns, rather
than the whole table.
Is this possible?


http://www.syncfusion.com/FAQ/WinFor...c44c.asp#q708q
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 20 '05 #2
Cor
Hi What-a-tool,
Have an Access table loaded into a DataTable that was created at run time,
and am displaying these contents in a data grid.
Me.dgGames.DataSource = Me.DsGameInfo.Tables("Games") I would like to display only a selected few of the columns, rather than the
whole table.


Take a look for "datarow", I think that will explain it for you.
(It is one or more rows from your table that has columns).

I hope this brings you on the route for the solution.
Cor
Nov 20 '05 #3
Hi,

If we are speaking of the System.Windows.Forms.DataGrid class, this is
definitely possible.
In the Windows Forms designer, click on the grid and choose the TableStyles
property in the Properties window. Then click on the small button with
ellipsis (...) to the right of the property name to bring up the Table
Styles Collection Editor. Add a new item and set its MappingName to "Games".
Then, go to the property grid for the newly created table style and choose
the GridColumnStyles property. Click on the similar button with ellipsis
(...) to bring up the Grid Column Styles Collection Editor. Add a number of
columns you want and specify header name and mapping name for each column.
Mapping names for the columns should correspond to the names of data columns
in the data table.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"What-a-Tool" <Fr***********************@cox.net> wrote in message
news:mSMcb.15428$0Z5.1761@lakeread03...
Have an Access table loaded into a DataTable that was created at run time,
and am displaying these contents in a data grid.
Me.dgGames.DataSource = Me.DsGameInfo.Tables("Games")

I would like to display only a selected few of the columns, rather than the whole table.
Is this possible?
Thanks - Sean


Nov 20 '05 #4
"What-a-Tool" <Fr***********************@cox.net> schrieb
Have an Access table loaded into a DataTable that was created at run
time, and am displaying these contents in a data grid.
Me.dgGames.DataSource = Me.DsGameInfo.Tables("Games")

I would like to display only a selected few of the columns, rather
than the whole table.
Is this possible?
Thanks - Sean


This is a question about the Datagrid and not specific to the VB.NET
language. Please turn to one of the
microsoft.public.dotnet.framework.windowsforms groups.
--
Armin

Nov 20 '05 #5
Thanks again -guys. Your the best. I'd be one frustrated aspiring programmer
if it wasn't for this group (still am frustrated most of the time - but not
quite as frustrated as I would be!).
Thanks-Sean

"What-a-Tool" <Fr***********************@cox.net> wrote in message
news:mSMcb.15428$0Z5.1761@lakeread03...
Have an Access table loaded into a DataTable that was created at run time,
and am displaying these contents in a data grid.
Me.dgGames.DataSource = Me.DsGameInfo.Tables("Games")

I would like to display only a selected few of the columns, rather than the whole table.
Is this possible?
Thanks - Sean

Nov 20 '05 #6
Or try this

Dim dgtsAdj As DataGridTableStyle

Private Sub SetDataGrid()
Try
Dim sFilter As String
sFilter = "Code = '" & tbCode.Text.Trim & "'"
dvViewAdj.RowFilter = sFilter

dgtsAdj = New DataGridTableStyle
dgtsAdj.MappingName = "Adjustments"

With dgActiveAdj
.DataSource = dvViewAdj
.AllowSorting = True
End With

dgActiveAdj.TableStyles.Clear()
dgActiveAdj.TableStyles.Add(dgtsAdj)
dgActiveAdj.TableStyles(0).ReadOnly = True

With dgtsAdj
.GridColumnStyles(0).Width = 0 'MAKES THEM HIDDEN
.GridColumnStyles(1).Width = 0
.GridColumnStyles(2).Width = 150
.GridColumnStyles(2).HeaderText = "Adjustment Description"
.GridColumnStyles(3).Width = 150
.GridColumnStyles(3).HeaderText = "Adjustment Amount"
.GridColumnStyles(4).Width = 85
.GridColumnStyles(4).HeaderText = "Begin Date"
.GridColumnStyles(5).Width = 85
.GridColumnStyles(5).HeaderText = "End Date"
End With
Catch ex As Exception
MessageBox.Show(ex.Source.ToString & " - " & ex.Message,
Application.ProductName, _
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try

End Sub

Nov 20 '05 #7
Ended up using the following to hide unwanted columns and set the width of a
column. Now I want to re-arrange the displayed order of the columns, so I
tried creating another table style and adding the columns in the order I
wanted them, but for some reason I end up with all table style settings
gone. Anyone see what I'm doing wrong?
Thanks - Sean

'Hide un-wanted column
Me.DsGameInfo.Tables("Games").Columns("Home").Colu mnMapping =
MappingType.Hidden

'Set column widths

Dim dgts As New DataGridTableStyle()

dgts.MappingName = "Games"

Me.dgGames.TableStyles.Add(dgts)

dgts.GridColumnStyles("Game").Width = 150

'Re-arrange colums

Dim dgts2 As New DataGridTableStyle()

dgts2.GridColumnStyles.Add(dgts.GridColumnStyles(" Game"))

dgts2.GridColumnStyles.Add(dgts.GridColumnStyles(" Home Score"))

dgts2.GridColumnStyles.Add(dgts.GridColumnStyles(" Guest Score"))

dgts2.GridColumnStyles.Add(dgts.GridColumnStyles(" Week / Year"))

Me.dgGames.TableStyles.Remove(dgts)

Me.dgGames.TableStyles.Add(dgts2)

Me.dgGames.Refresh()

"What-a-Tool" <Fr***********************@cox.net> wrote in message
news:mSMcb.15428$0Z5.1761@lakeread03...
Have an Access table loaded into a DataTable that was created at run time,
and am displaying these contents in a data grid.
Me.dgGames.DataSource = Me.DsGameInfo.Tables("Games")

I would like to display only a selected few of the columns, rather than the whole table.
Is this possible?
Thanks - Sean

Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: pmud | last post by:
Hi, I have 4 columns in my sql database table. I added a data adapter , data set & a data grid to view this information. But the data grid is displaying those 4 columns TWICE , i.e in the data...
13
by: Aladdin | last post by:
I have an MS Access form on which I have a listbox listing tables in that database. I want to be able to click on any of those tables and view its contents on the same form using subforms or any...
3
by: Diego TERCERO | last post by:
Hi... I'm working on a tool for editing text resources for a family of software product my company produces. These text resources are found in a SQL Server database, in a table called...
5
by: Lisa Calla | last post by:
Hi, I need to display records with lots of fields. When placed in a grid, a row of data will scroll off the screen. Not exactly what I'm looking for. I've also used a datalist, which allows...
1
by: thf | last post by:
Hi, I wish to know how to display a collection of object which is a property in another object in a data grid in VB.Net. For example, I'm displaying a collection of vendor objects (in ArrayList)...
3
by: William LaMartin | last post by:
I have a gridview (with no properties set) on an aspx page which I populate from an XML file with the code below. The data in the XML file looks like this <description>National Trust for...
3
by: RichT | last post by:
Hi all, I am experiencing some odd behaviour with a DataGridView. The DataGridView is bound to a DataTable, which is populated with data from a csv file. The column Headings appear fine,...
0
by: Scott | last post by:
Hello all and thanks in advance for any help you may be able to offer me. I am quite new to asp.net and am trying to work with a datagrid but am having some problems with it. Here's the...
0
by: cadab | last post by:
I have a data grid view, i have specified several columns through the designer that i would like to show on the grid, i have mapped them to the datasource, this works fine, the problem is, my data...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.