By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,187 Members | 1,594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,187 IT Pros & Developers. It's quick & easy.

Hiding Columns in datagrid

P: n/a
Hi,
I am using a datagrid on a windows form. The datasource of the grid is bound
to a class array. It works just fine. But I am not sure how to hide some
columns in the grid programmatically. Any suggestions in this regard will be
greatly appreciated.
Bhargavan M
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
You will want to use a datagridtable style.

DataGridTableStyle dts = new DatagirdTableStyle();
dts.MappingName = "The TYPE name of your class collection, e.g: 'ArrayList'
for an arraylist or if you are using a datatable the tablename of the
table";
DataGridTextBoxColumn textCol = new DataGridTextBoxColumn();
textCol.MappingName = "NameOfPublicProperty";
textCol.HeaderName = "Header";
dts.GridColumnStyles.Add(textCol);
this.dataGrid1.TableStyles.Add(dts);

Now the datagrid will show ONLY the columns specified in the tablestyle, all
other columns will be ignored, if you don't get the Mapping name right it
will display as normal.
"Bhargavan" <bh********@yahoo.co.in> wrote in message
news:Of**************@TK2MSFTNGP14.phx.gbl...
Hi,
I am using a datagrid on a windows form. The datasource of the grid is bound to a class array. It works just fine. But I am not sure how to hide some
columns in the grid programmatically. Any suggestions in this regard will be greatly appreciated.
Bhargavan M

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.