cpopham Posted January 3, 2005 Posted January 3, 2005 How do I hide the first column of a datagrid control or set its width to zero? Thanks, Chester Quote ____________________________________________ http://www.pophamcafe.com I am starting a developers section, more tutorials than anything.
AlexCode Posted January 3, 2005 Posted January 3, 2005 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: YourDataTable.Columns("ColumnNameToHide").ColumnMapping = MappingType.Hidden Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
cpopham Posted January 3, 2005 Author Posted January 3, 2005 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. Quote ____________________________________________ http://www.pophamcafe.com I am starting a developers section, more tutorials than anything.
AlexCode Posted January 3, 2005 Posted January 3, 2005 Ok... but your dataview comes from a datatable... If you use that on the source table of you dataview it should work... Alex :p Quote Software bugs are impossible to detect by anybody except the end user.
UchihaJax Posted January 10, 2005 Posted January 10, 2005 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. Quote
AlexCode Posted January 10, 2005 Posted January 10, 2005 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 Quote Software bugs are impossible to detect by anybody except the end user.
donnacha Posted January 11, 2005 Posted January 11, 2005 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..... Quote Hamlet
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.