DataGridView change row color

  • Thread starter Thread starter Tony B
  • Start date Start date
T

Tony B

Hi,
I'm trying to change the background color of a row in a DataGridView
based upon a value in one of the row columns

For i As Integer = 0 To myDataGridView.Rows.Count - 1
If CInt(myDataGridView.Rows(i).Cells(12).Value) = 2 Then

myDataGridView.Rows(i).DefaultCellStyle.BackColor = Color.Red

End If
Next

I've stepped through the code so I know that the value of cell 12 is
being pulled out and the line
myDataGridView.Rows(i).DefaultCellStyle.BackColor = Color.Red
is executed but the background color isn't changed.

Any suggestions?

Tony
 
Back
Top