Try it (Note: I don't have Visual Studio right now, so the code is to copy the paste from my archive (I have not tested it):
Private Sub DataGridView1_CellFormatting(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting Dim drv As DataRowView If e.RowIndex >= 0 Then If e.RowIndex <= ds.Tables("Products").Rows.Count - 1 Then drv = ds.Tables("Products").DefaultView.Item(e.RowIndex) Dim c As Color If drv.Item("Quantity").Value < 5 Then c = Color.LightBlue Else c = Color.Pink End If e.CellStyle.BackColor = c End If End If End Sub
Nianios
source share