vb.net Code:
  1. Private Sub DataGridView1_CellPainting(sender As System.Object, e As System.Windows.Forms.DataGridViewCellPaintingEventArgs) Handles DataGridView1.CellPainting
  2.         Dim c As Drawing.Color
  3.         For i = 0 To DataGridView1.Rows.Count - 1
  4.             Select Case CInt(DataGridView1.Rows(i).Cells(0).Value)
  5.                 Case 1
  6.                     c = Color.AliceBlue
  7.                 Case 2
  8.                     c = Color.Bisque
  9.                 Case 3
  10.                     c = Color.Coral
  11.                 Case Else
  12.                     c = Color.White
  13.             End Select
  14.             DataGridView1.Rows(i).Cells(0).Style.BackColor = c
  15.         Next
  16.     End Sub