Hide first colomun of a datagrid

cpopham

Junior Contributor
Joined
Feb 18, 2004
Messages
273
How do I hide the first column of a datagrid control or set its width to zero?

Thanks,
Chester
 
I don't use the datagrid... I don't know , but it may be possible to set the column width to 0 but... forget it...
Never relly on UI (controls) to manipulate this kind of issue.

Certainlly you have the DataGrid control bound to a DataTable right?
So, on that DataTable set this:
Visual Basic:
YourDataTable.Columns("ColumnNameToHide").ColumnMapping = MappingType.Hidden

Alex :p
 
I do not use datagrids much either, but I am attempting some manipulations where the datagrid will work really well. I am using a dataview for my datagrid.
 
Ok... but your dataview comes from a datatable...
If you use that on the source table of you dataview it should work...

Alex :p
 
Try using a DataGridTableStyle.
Use the mapping property of each DataGridTextBoxColumn to map to a certain column.
E.G.

DataGridTableStyle dts = new DataGridTableStyle();
DataGridTextBoxColumn textCol = new DataGridTextBoxColumn();
textCol.MappingName = "TaskID";
textCol.HeaderText = "The Task ID";
dts.GridColumnStyles.Add(textCol);
dataGrid1.TablesStyles.Add(dts);

Any columns you dont map wont be shown.
 
That is an option but we shouldn't relly on a UI Control for this business issue, and this gets more significant if we're talking about the .net DataGrid.

If you manage the data from the datasource you can safelly upgrade the UI controls that no damage or recoding will be donne...

Alex :p
 
The way to do this is to use the DataGridTableStyle and set the colume width to 0 or just leave the colume out of the table style altogether. Sometimes it is better to set the width to 0 in case you want to access all the data in the datagrid as opposed to its datasource. It depends on your needs.....
 
Back
Top