Home All Groups Group Topic Archive Search About

How to hide one column in datagrid?

Author
10 Feb 2006 10:41 AM
Sidney
Hi~
I want to know if I want to hide a column in datagrid because I don't want
to show that column of data.
How can I do this?

Sidney

Author
9 Feb 2006 11:46 PM
Cerebrus99
Well, I think it depends on what is the DataSource for your Datagrid. If you
are loading data from a DataSet or DataTable, you might prefer not to load
that particular column at all, into your DataSet.

Additionally, to create a customized view of a table, create a collection of
DataGridColumnStyle objects, and set each column's MappingName to the
ColumnName of a column that you want to show in the grid. To hide a column,
set its MappingName to something other than a valid ColumnName.

Hope this helps,

Regards,

Cerebrus.
Author
10 Feb 2006 1:19 PM
g.moralis
Create a DataGridTableStyle, set its MappingName to the name of your
table, create DataGridColumnStyle objects for each of your column,
setting the MappingName equal to the ColumnName and add them to the
DataGridTableStyle. Add the table style to the DataGrid's TableStyles
collection. Then you can hide the desired column by setting the Width
property of DataGridColumnStyle object of the specific column equal to
0

Regards
GM
Author
10 Feb 2006 1:40 PM
Cor Ligthert [MVP]
Sidney,

Another method, be aware that it hides than the column everywhere.

http://www.vb-tips.com/default.aspx?ID=76a81eb8-ea2d-48f4-99c3-a3539697edbd

I hope this helps,

Cor
Author
10 Feb 2006 2:27 PM
Sonu Kapoor
DataGrid1.Columns(0).Visible = False

Sonu Kapoor [MVP]
---
Posted via www.DotNetSlackers.com