user6167266 user6167266 - 5 months ago 30
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

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