Help with changing rows backcolor

Hi,

How do you change rows backcolor if after column 3, data in remaining rows are identical, using vb.net?

Thanks

Victor
vcharlesAsked:
Who is Participating?
 
CodeCruiserCommented:
Something like below (untested)

For i As Integer = 0 to dgv.Rows.Count - 1
   If i < dgv.Rows.Count - 2 Then
      if dgv.Rows(i).Cells(3).Value = dgv.Rows(i+1).Cells(3).Value AND dgv.Rows(i).Cells(4).Value = dgv.Rows(i+1).Cells(4).Value AND ... Then
         dgv.Rows(i).DefaultCellStyle.BackColor = Color.Red
         dgv.Rows(i+1).DefaultCellStyle.BackColor = Color.Red
      End If
   End If
Next
0
 
Karrtik IyerSoftware ArchitectCommented:
Hi Victor, is this for a data grid control in VB.NET that you are talking about?
Please specify for which control are you looking to change the back color.

Thanks and regards,
Karrtik
0
 
vcharlesAuthor Commented:
Hi,

Thanks for the comments, it is the datagridview that comes with VS2010.
0
 
CodeCruiserCommented:
Have you tried the code provided above?
0
 
vcharlesAuthor Commented:
Hi,

I did not try it yet, will reply this week.

Thanks,

V.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.