Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using Microsoft Visual Studio 2005

How do i make a DGV row color red depending on it's content?
i have this table:

VB
   Name    ID    deleted
charlotte   1       y
   jay      1       n
   rose     1       y
   hale     1       y
   mike     1       n


and this code:
VB
Dim a As Integer = 0
        While a <> DGVpeople.RowCount

            If DGVpeople.Rows(a).Cells(2).Value = "y" Then
                'Code to make the row red?
            End If
            a = a + 1
        End While
    End Sub


how do make the row of the ones with 'y' in the deleted column be color red?
Posted

VB
For Each row As DataGridViewRow In DGVpeople.Rows
	If row.Cells(2).Value = "y" Then
		row.DefaultCellStyle.BackColor = Color.Red
	End If
Next
 
Share this answer
 
v2
Comments
charliedev 2-Jul-14 2:48am    
thanks
Should
While a <> DGVpeople.RowCount

be
While a < DGVpeople.RowCount

and
DGVpeople.Rows(a).DefaultCellStyle.BackColor = Color.Red
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900