Hi! How can I display only selected headers in DataGridView control? For example I have DataTable with headers ("Name","Age","Status"), but I'd like to omit "Age" column when displaying.
Thanks! :)
Hi! How can I display only selected headers in DataGridView control? For example I have DataTable with headers ("Name","Age","Status"), but I'd like to omit "Age" column when displaying.
Thanks! :)
in the DataBindingComplete() method:
this.dataGridView1.Columns["Age"].Visible = false;
ref: How to: Hide Columns in the Windows Forms DataGridView Control
Personally I'd probably add the columns that I do want manually (AutoGenerateColumns=false
), rather than try to take away the ones I don't want.
If this was a class model (rather than DataTable
) you can do things like setting [Browsable(false)]
on properties you never want to see. With . Other than that, you simply just Add the columns you want.DataTable
I wonder if you can't do something with a non-default DataView
...