V e události RowPrePaint je index řádku, který se zrovna vykresluje.
Private CellStyle As DataGridViewCellStyle
Private Sub Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load
CellStyle = New DataGridViewCellStyle()
CellStyle.BackColor = Color.FromArgb(255, 242, 243)
End Sub
Private Sub DataGridView_RowPrePaint(sender As Object, e As DataGridViewRowPrePaintEventArgs) Handles DataGridView.RowPrePaint
If DataGridView.Rows(e.RowIndex).Cells(7).Value < 0 Then
DataGridView.Rows(e.RowIndex).Cells(7).Style = CellStyle
Else
DataGridView.Rows(e.RowIndex).Cells(7).Style = Nothing
End If
End Sub
|