Problem : no handles clause at the end of your sub.
You have to declare your function with handles clause .
Handles clause defines which control to bind this event. that should be your datagridview
Private Sub DataGridView1_CellFormatting(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) _
Handles DataGridView1.CellFormatting
For i As Integer = 0 To Me.DataGridView1.Rows.Count - 1
If Trim(Me.DataGridView1.Rows(i).Cells("Status").Value) = "Pending" Then
Me.DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.Green
Me.DataGridView1.Rows(i).DefaultCellStyle.ForeColor = Color.White
ElseIf Trim(Me.DataGridView1.Rows(i).Cells("Status").Value) = "Close" Then
Me.DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.Red
Me.DataGridView1.Rows(i).DefaultCellStyle.ForeColor = Color.White
ElseIf Trim(Me.DataGridView1.Rows(i).Cells("Status").Value) = "In Progress" Then
Me.DataGridView1.Rows(i).DefaultCellStyle.BackColor = Color.Orange
Me.DataGridView1.Rows(i).DefaultCellStyle.ForeColor = Color.White
End If
Next
End Sub
Its not the problem of integer or of string.
'trim added for removing spaces as stated by CHill60