for example if I want to make certain column header hidden in Datagridview. I'll use this code:
dataGridView1.ColumnHeadersVisible = false;
But this will make all the column header to be invisible. Now what if I want only certain column header to be hidden.
For instance I have 3 column header. I just want the 3rd column header to be invisible without hidden all the rows data belongs to that column. Is that possible?
Please advise and correct me if I'm wrong.
You will need to handle the DataGridView.CellPainting Event.
In the event handler you will be given an instance of DataGridViewCellPaintingEventArgs. You can use the ColumnIndex and RowIndex properties of this object to determine if a header cell you want to hide is being painted. RowIndex will be -1 if the cell being painted is a column header.
It may just be a simple matter of doing nothing except e.Handled = true; when the header cell in question is being painted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With