473,606 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Data Source = Me.DsGameInfo.T ables("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 14664
"What-a-Tool" <Fr************ ***********@cox .net> wrote in
news:mSMcb.1542 8$0Z5.1761@lake read03:
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.Data Source = Me.DsGameInfo.T ables("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********@rog ers.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.Dat aSource = Me.DsGameInfo.T ables("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 GridColumnStyle s 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.1542 8$0Z5.1761@lake read03...
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.Data Source = Me.DsGameInfo.T ables("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.Data Source = Me.DsGameInfo.T ables("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.publi c.dotnet.framew ork.windowsform s 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.1542 8$0Z5.1761@lake read03...
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.Data Source = Me.DsGameInfo.T ables("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 DataGridTableSt yle

Private Sub SetDataGrid()
Try
Dim sFilter As String
sFilter = "Code = '" & tbCode.Text.Tri m & "'"
dvViewAdj.RowFi lter = sFilter

dgtsAdj = New DataGridTableSt yle
dgtsAdj.Mapping Name = "Adjustment s"

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

dgActiveAdj.Tab leStyles.Clear( )
dgActiveAdj.Tab leStyles.Add(dg tsAdj)
dgActiveAdj.Tab leStyles(0).Rea dOnly = True

With dgtsAdj
.GridColumnStyl es(0).Width = 0 'MAKES THEM HIDDEN
.GridColumnStyl es(1).Width = 0
.GridColumnStyl es(2).Width = 150
.GridColumnStyl es(2).HeaderTex t = "Adjustment Description"
.GridColumnStyl es(3).Width = 150
.GridColumnStyl es(3).HeaderTex t = "Adjustment Amount"
.GridColumnStyl es(4).Width = 85
.GridColumnStyl es(4).HeaderTex t = "Begin Date"
.GridColumnStyl es(5).Width = 85
.GridColumnStyl es(5).HeaderTex t = "End Date"
End With
Catch ex As Exception
MessageBox.Show (ex.Source.ToSt ring & " - " & ex.Message,
Application.Pro ductName, _
MessageBoxButto ns.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.T ables("Games"). Columns("Home") .ColumnMapping =
MappingType.Hid den

'Set column widths

Dim dgts As New DataGridTableSt yle()

dgts.MappingNam e = "Games"

Me.dgGames.Tabl eStyles.Add(dgt s)

dgts.GridColumn Styles("Game"). Width = 150

'Re-arrange colums

Dim dgts2 As New DataGridTableSt yle()

dgts2.GridColum nStyles.Add(dgt s.GridColumnSty les("Game"))

dgts2.GridColum nStyles.Add(dgt s.GridColumnSty les("Home Score"))

dgts2.GridColum nStyles.Add(dgt s.GridColumnSty les("Guest Score"))

dgts2.GridColum nStyles.Add(dgt s.GridColumnSty les("Week / Year"))

Me.dgGames.Tabl eStyles.Remove( dgts)

Me.dgGames.Tabl eStyles.Add(dgt s2)

Me.dgGames.Refr esh()

"What-a-Tool" <Fr************ ***********@cox .net> wrote in message
news:mSMcb.1542 8$0Z5.1761@lake read03...
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.Data Source = Me.DsGameInfo.T ables("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
1950
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 grid i see 8 columns. In case this is useful, the primary key is Serial no. which is an identity ....i.e everytime a row is added to the database, it increments by1. Also, when i configured the data adapter, it couldnt Generate the UPDATE &...
13
3597
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 grid control. I tried many grid controls (DBGrid, DataGrid, MSFlexGrid), the ADO Data Control and everything I can think of, with no success. Here are the contraints I faced: (1) Populating any of the grid controls manually is too slow for my...
3
2536
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 "Resource" with the following structure : Resource{,en,fr,es} Yes.. these are the only languages supported actually. A couple of rows in that table would look like this :
5
1399
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 multiple lines for a single row of data (yes! no horizontal scrolling!), but columns do not line up across listitems/data rows (very ugly & distracting - maybe there's some way to get the items to line up, but I haven't found it). This has to be a...
1
1487
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) in a data grid, while I wish to display the products supplied by the vendor (which appears as a collection of product objects in the vendor object property) in another grid. I wish to know how can I accomplish such task. I used data...
3
3121
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 Historic Preservation</description> <URL>http://www.nthp.org/</URL> <category>Architecture</category> Can anyone tell me why the other two columns are displayed, but the
3
2288
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, but the data only appears if I select a cell otherwise the DGV look empty apart from the selected cell.
0
2577
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 problem... My datagrid displays 2 columns of checkboxes and allows the user to select the check boxes and sort the datagrid. My first problem, if
0
2734
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 source contains lots of columns and some of these i do not want to show on the grid. Is there a property/option where i can just get my specified columns to show, without resorting to removing each column programticly. Thanks, James Coverdale
0
8015
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7951
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8430
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8305
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
3930
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3977
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2448
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.