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

How to hide one column in datagrid?

P: n/a
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
Feb 10 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
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.
Feb 10 '06 #2

P: n/a
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

Feb 10 '06 #3

P: n/a
Sidney,

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

http://www.vb-tips.com/default.aspx?...3-a3539697edbd

I hope this helps,

Cor
Feb 10 '06 #4

P: n/a
DataGrid1.Columns(0).Visible = False

Sonu Kapoor [MVP]
---
Posted via www.DotNetSlackers.com
Feb 10 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.