How to set border color of datagridview header boxes

GridColor property of the DataGridView can set the color of the grid lines separating the DataGridView cells (i.e. the borders of each cell).

But it cannot change the color of the grid lines of the header cells (i.e. the borders of the header cells).
How can I achieve this?
Is there a property that I can use for this?

1.Change GridColor property
using <code> GridColor </code> property
2.Changing My Requirement
enter image description here

As stated in TnTinMn, the GridColor property GridColor affects cells with CellBorderStyle= DataGridViewCellBorderStyle.Single .
The result is as follows.
It cannot affect the grid lines separating the header cells.

CellBorderStyle enter image description here

After another attempt, I will succeed.
4.Changing the use of `EnableHeadersVisualStyles = false ' enter image description here

( Solution ) To summarize:
1.Using GridColor to set the color of the grid lines.
2. Set CellBorderStyle , ColumnHeadersBorderStyle , RowHeadersBorderStyle to Single .
EnableHeadersVisualStyles to false .

+5
source share
1 answer

Do the 3 things you indicated, and then:

  1. Set CellBorderStyle = DataGridViewCellBorderStyle.Raised - this will allow your coloring to appear only in the header, but since now you have set the border of the body cell to a 3D type (i.e. raised , sunken , etc., rather than single or none , etc. etc.), the body cell will have a default system style (may be gray).

Example

0
source

All Articles