How to hide one column in datagrid?

C

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.
 
S

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
 
G

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top