1 Attachment(s)
[RESOLVED] DataGridView - setting the colour of a row?
I have a dgv where every alternating row is a different colour to make it more readable, as you can see in my attachment.
I now want to recolour certain rows to another colour. Lets for example say all rows where column(7).value < 5 should be red or whatever.
I coloured 2 rows in the example to show you what i want.
Is this possible?
if yes, how?
Attachment 78922
Re: DataGridView - setting the colour of a row?
vb Code:
Me.DataGridView1.Rows(2).DefaultCellStyle.BackColor = Color.Red
Re: [RESOLVED] DataGridView - setting the colour of a row?
For future reference, this is the code i use in my DGV
vb Code:
Private Sub ColourMixedItems()
Dim tmp As String
Dim i As Integer = 0
Dim counter As Integer = DGVReceipt.Rows.Count
Do Until i = counter
tmp = DGVReceipt(2, i).Value
If tmp <> Nothing Then
If tmp.EndsWith("M") Then
DGVReceipt.Rows(i).DefaultCellStyle.BackColor = Color.LemonChiffon
End If
End If
i += 1
Loop
End Sub