all groups > vb.net data > january 2005 >
You're in the

vb.net data

group:

How do I hide a column from an autogenerated grid


How do I hide a column from an autogenerated grid Viet
1/7/2005 11:48:44 AM
vb.net data: Does anyone know how to hide a particular column from an autogenerated grid?
Below is what I have done to read a XML file and display the data onto a
grid. The first column (ID) does not get hidden.

I have read that once cannot easily hide columns in the autogenerated grid
but most of the examples I see are for ASP.NET and not VB.NET. Does anyone
know???


Code:

ds.ReadXml(sRemittanceFile, XmlReadMode.Auto)

With DataGrid1
.DataSource = ds
.DataMember = "row"
FormatGrid()
End With

Private Sub FormatGrid()
Dim ts As New System.Windows.Forms.DataGridTableStyle()
ts.MappingName = "ID"

Dim Col1 As New System.Windows.Forms.DataGridTextBoxColumn()
Col1.MappingName = "ID" 'Actual Column Name
Col1.HeaderText = "ID"
Col1.Width = 0
ts.GridColumnStyles.Add(Col1)
End Sub


RE: How do I hide a column from an autogenerated grid sstein NO[at]SPAM online.microsoft.com (
1/10/2005 8:39:38 PM
Jonathan,

Check out the DataGrid section of the Windows Form FAQ site
(http://www.syncfusion.com/FAQ/WinForms/)


' Hide the column and attach dataset's DefaultView to the datagrid control
ds.Tables("Employees").Columns("LastName").ColumnMapping =
MappingType.Hidden
dataGrid1.DataSource = ds.Tables("Employees")

hope that helps

Steve Stein
VB Team

This posting is provided "AS IS" with no warranties and confers no rights.

--------------------
| From: "Viet" <vpho@starcalif.com>
| Subject: How do I hide a column from an autogenerated grid
| Date: Fri, 7 Jan 2005 11:48:44 -0800
| Lines: 32
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
| Message-ID: <#HycmHP9EHA.3260@TK2MSFTNGP14.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.vb.data
| NNTP-Posting-Host: starcalif.com 65.168.176.131
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP14
.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.languages.vb.data:4620
| X-Tomcat-NG: microsoft.public.dotnet.languages.vb.data
|
| Does anyone know how to hide a particular column from an autogenerated
grid?
| Below is what I have done to read a XML file and display the data onto a
| grid. The first column (ID) does not get hidden.
|
| I have read that once cannot easily hide columns in the autogenerated grid
| but most of the examples I see are for ASP.NET and not VB.NET. Does anyone
| know???
|
|
| Code:
|
| ds.ReadXml(sRemittanceFile, XmlReadMode.Auto)
|
| With DataGrid1
| .DataSource = ds
| .DataMember = "row"
| FormatGrid()
| End With
|
| Private Sub FormatGrid()
| Dim ts As New System.Windows.Forms.DataGridTableStyle()
| ts.MappingName = "ID"
|
| Dim Col1 As New System.Windows.Forms.DataGridTextBoxColumn()
| Col1.MappingName = "ID" 'Actual Column Name
| Col1.HeaderText = "ID"
| Col1.Width = 0
| ts.GridColumnStyles.Add(Col1)
| End Sub
|
|
|
|
AddThis Social Bookmark Button