I have a DataGridView in a WinForm. I fill the DataGridView from a database table. I was wondering if there is any way to program my DataGridView so that I can choose which columns I want the gridview to show at runtime?
I have a DataGridView in a WinForm. I fill the DataGridView from a database
Share
The simple answer is “yes”.
In the first instance you need to set the
AutoGenerateColumnsproperty of theDataGridViewto false then you can control which columns get displayed.In the past I’ve created a context menu for the DGV:
Then when the the menu option is toggled change the
Visibleproperty of the column.