DataGridView change row color

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top