user6167266 user6167266 - 1 year ago 149
Vb.net Question

Change colour of DataGridViewCheckBoxColumn?

I have the following code to add a checkbox column to my grid..

Dim excludeColumn As New DataGridViewCheckBoxColumn
With excludeColumn
.Name = "(excl)"
.DataPropertyName = "exclude"
.Width = 300
.Visible = True
.DefaultCellStyle.ForeColor = Color.LightBlue
End With
.Columns.Add(excludeColumn)


Why doesn't the colour of the
DefaultCellStyle
property change as required above?

Answer Source

You want the .BackColor property. .ForeColor changes the text color which isn't present on a checkbox column.