I was wondering if there is an easier way to hide unwanted columns in a dataGridView when setting the DGVs datasource to a dataTable. Basically I run a query against a database populating a data set (and hence a dataTable). I am setting the dataGridView's data source to the dataTable in the DataSet. However, I only want to display some of the columns. I've defined all of the columns and their dataProperty in the defined dataGridView. However, when I set the DataSource to the dataTable I've loaded, I see all of the columns. Right, now I am having to hide all of the unwanted columns via the "Columns.Visible" property to false. Kind of a pain since I know which columns I want displayed. Is there a way to tell the DGV to only display the column that are already defined in the DGV and not to display any other columns that may be added as a result of loading the DataTable? Hopefully this makes sense. I'll give an example...
The dataGridView I've defined say has 3 columns (A, B, and C). The dataTable I load has columns A, B, C, D, and E. When I set the dataSource to the dataTable, all of the queried columns appear in the dataGridView (A-E). Do I have to manually set the visible property of D and E to False or is there a way to tell the DGV to only display the defined columns (A-C)?
Thanks
Greg
The dataGridView I've defined say has 3 columns (A, B, and C). The dataTable I load has columns A, B, C, D, and E. When I set the dataSource to the dataTable, all of the queried columns appear in the dataGridView (A-E). Do I have to manually set the visible property of D and E to False or is there a way to tell the DGV to only display the defined columns (A-C)?
Thanks
Greg