I have datagridview which is populated with 3 columns partno,locality,houseno. Initially my row colour would be say light blue. Now what i want is whenever houseno changes in row,its row colour should be changed to say grey. That means whenever houseno changes,these two colours should be alternately applied to rows of grid.
For example,values that would be populated in houseno column will be
0
0
1
1
2
etc.Now for row with houseno 0 will have row colour as light blue ,for houseno 1 will have row colour grey,for houseno 2 again light blue and so on.
Can any1 help me with this.
Thanks in advance.
Rachna0309
0
Light Poster
Recommended Answers
Jump to PostTry something like:
Dim last_value As String = "" Dim last_color As Color = Color.LightBlue If DataGridView1.Rows.Count > 0 Then For Each row In DataGridView1.Rows If DataGridView1.Item("houseno", row.index).Value <> last_value Then If last_color = Color.LightBlue Then DataGridView1.Rows(row.index).DefaultCellStyle.BackColor = Color.LightGray Else DataGridView1.Rows(row.index).DefaultCellStyle.BackColor = Color.LightBlue End If Else …
All 3 Replies
adam_k
239
Master Poster
Reverend Jim
4,780
Hi, I'm Jim, one of DaniWeb's moderators.
Moderator
Featured Poster
Rachna0309
0
Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.