GridColor
property of DataGridView
can set the color of the grid lines separating the cells of the DataGridView
(i.e. borders of every cell).
But it can't change the grid lines' color of header cells(i.e. borders of header cells).
How can I achieve this?
Is there a property that I can use to accomplish this?
1.image of using GridColor
property
2.image of My requirement
As TnTinMn said, the GridColor
property only affects cells with CellBorderStyle= DataGridViewCellBorderStyle.Single
.
The result is like the following image.
It can't affect the grid lines seperating the header cells.
3.image of using CellBorderStyle
property
After another try, I succeed.
4.image of using `EnableHeadersVisualStyles = false'
(Solution)To summarize:
1.Using GridColor
to set the color of grid lines.
2.Set CellBorderStyle
,ColumnHeadersBorderStyle
,RowHeadersBorderStyle
to Single
.
3.Set EnableHeadersVisualStyles
to false
.
Do the 3 things you listed, and then:
CellBorderStyle = DataGridViewCellBorderStyle.Raised
- this will allow your colouring to show up in the header only, but because you've now set the body cell border to a 3D type (i.e. raised
, sunken
etc, not single
or none
etc), the body's cell will have a system default styling (likely to be grey).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