column not being hidden

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have reseached and the following code should hide my column, but it does
not any ideals?

Dim InvDataGrid As DataTable

dgInv.TableStyles.Clear()

InvDataGrid = New DataTable("InvData")
InvDataGrid.Columns.Add("Inv", Type.GetType("System.String"))
InvDataGrid.Columns.Add("ItemID", Type.GetType("System.String"))
InvDataGrid.Columns.Add("DueDate", Type.GetType("System.String"))
InvDataGrid.Columns.Add("Sel", Type.GetType("System.String"))
InvDataGrid.Columns.Add("Index", Type.GetType("System.String"))

'hide the index column
InvDataGrid.Columns(5).ColumnMapping = MappingType.Hidden
 
It's hidden, but only in the XML file. Here's quote from VS documentation
on ColumnMapping property:

"The ColumnMapping property determines how a DataColumn is mapped when a
DataSet is saved as an XML document using the WriteXml method."

Look into DataGridColumnStyle class to hide column in the DataGrid.

Best regards,

Ilya

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

--------------------
 
Hello,

Work around is right, but if the column header is dragged then it will
show the data that you have set the width to 0.
Use DataGridColumnStyle to set the width for all the column and leave
not specifying anything for the specific column that you are trying to
hide. This will help you to hide the column better.
Hope you understood.

Cheers,
Arun.
www.innasite.com
 
Back
Top