Change DataGridView Row color based on cell value?

  • Thread starter Thread starter Shan1986
  • Start date Start date
S

Shan1986

Guest
Hi,

I am trying to change to color of an entire row when one of the column cell meets the specific condition. I tried following codes but non of them seems to be working. I have AlternatingRowsDefaultCellStyle already applied.

Any idea to make it work


With dgv


For i = 0 To .Rows.Count - 1

If dgv.Rows(i).Cells(ColName).Value = Conditon Then
dgv.Rows(i).DefaultCellStyle.BackColor = Color.LightSkyBlue
dgv.Rows(i).DefaultCellStyle.BackColor = Color.Red

'dgv.Rows(i).Cells(ColName).Style.ForeColor = Color.Red
End If

Next


End With


Thanks

Continue reading...
 
Back
Top