Hide datagrid column

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

Guest

Is it possible to select which columns to display in a datagrid?
I have a column which is an ID which the user has no interest in, therefore
i don't want it to be displayed...
can that be done? how?
 
Of course it can be done,
I use this code :

datagrid.Columns(<the number of the column you want>).Visible = True
 
this looks very cool, but are you sure its not just for web forms?

I get 'Columns' is not a member of System.Windows.Forms.Datagrid :(

P.S. I am coding a Windows Form, not a Web Form
 
Hide the column before you attach the datasource:

ds.Tables("dtWhatever").Columns("ID").ColumnMapping = MappingType.Hidden

DataGrid1.DataSource = ds.Tables("dtWhatetever")
 
Back
Top