I'm using a DataGridView in a Windows Forms application in which I use DataGridViewCheckBoxColumns. The problem is that they have a standard selection backcolor which I can't seem to change. What I mean is the blue color in the checkboxes as can be seen in the image below.
I have tried to change the color like this (while looping trough the DataGridViewColumns in the initialization of the DataGridView):
if (col.GetType() == typeof(DataGridViewCheckBoxColumn))
{
col.CellTemplate.Style.SelectionBackColor = WinFormsUITheme.styleColor;
col.CellTemplate.Style.SelectionForeColor = WinFormsUITheme.styleColor;
}
But this doesn't work. How should this color be changed? Or is this not possible? Is there maybe a way to change the standard windows selection highlight color for a whole Windows forms project? Or maybe this should be done in the DataGridViewCellPainting event?

As I understand it, your goal is to have control over the selection back color and possibly the color of the fill on the checkboxes themselves.
This snippet manipulates the
DefaultCellStyle.SelectionBackColorof the entire DGV but you can override this for an individual cell using itsStyleproperty, or for a single column using the column'sDefaultCellStyle. So, if this is all you need to do, you don't necessarily have to custom paint at all.Your comment mentions the
CellPaintingevent and one decent way to handle it is by drawing a unicode text glyph. For example, the custom glyph font checkbox-icons.ttf used in the above screenshot was made on Fontello, set as an embedded resource, and loaded using the utility extension shown below.MainForm
Example Record Class
Font loading utility