With DataGrid_H
For i As Integer = 0 To .Rows.Count - 1
If CInt((DataGrid_H.Rows(0).Cells(2).Value) <= (DataGrid_H.Rows(0).Cells(3).Value)) Then
.RowsDefaultCellStyle.BackColor = Color.Red
End If
Next
End With
For i As Integer = 0 To DataGrid_H.RowCount - 1
If CDate(DataGrid_H.Rows(i).Cells(3).Value).Date >= Now.Date Then
DataGrid_H.Rows(i).DefaultCellStyle.BackColor = Color.Red
End If
Next
Private Sub dg_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles dgSub.CellFormatting
If e.ColumnIndex = 4 AndAlso sender.Rows(e.RowIndex).Cells("Balance").Value < 0 Then
e.CellStyle.ForeColor = Color.Red
e.CellStyle.BackColor = Color.LightCyan
End If
If e.ColumnIndex = 0 AndAlso sender.Rows(e.RowIndex).Cells("refDoc").Value = "ยกมา" Then
e.CellStyle.ForeColor = Color.DarkGreen
End If
End Sub