views:

18

answers:

1

Is there any way I can specify that some columns in a DataTable will not be automatically bound to a DataGridView when I set the DataSource property of the DataGridView to the DataTable.

For example, if I have a DataTable with columns as "Id, Name" then can I specify that Id column will not be shown in DataGridView? I know I can set some Visible property in DataGridView after it is bound, but can I specify in the DataTable/DataColumn itself?

A: 

It's best to setup the columns and their bindings.

How to: Add and Remove Columns in the Windows Forms DataGridView Control Using the Designer

Otherwise, you can remove the unwanted columns:

How to: Hide Columns in the Windows Forms DataGridView Control Using the Designer

David Neale
Unfortunately, I was not looking for that answer. Please read my question, esp. the last line "...can I specify in the DataTable/DataColumn itself?"
Rajarshi
You could manually copy the data you want from one DataTable to a new DataTable. But there's nothing in a DataTable to prevent certain fields from being data bound.
David Neale