Basit Khan

Basit Khan

  • 1.3k
  • 336
  • 115.3k

How to compare two DataGridView Values

Mar 24 2019 5:58 AM
Hi,
 
I have two DataGridView1 and DataGridView2 which is having same columns and rows.
 
How to compare between two grids.
 
I wrote the for loop but no success.
 
below is the code.
 
For Each rw1 As DataGridViewRow In DataGridView1.Rows
For Each rw2 As DataGridViewRow In DataGridView2.Rows
If rw1.Cells(3).Value <> rw2.Cells(3).Value Then
If Not rw1.Cells(3).Value Is Nothing Then
rw1.Cells(3).Style.BackColor = Color.Red
End If
End If
Next
Next
 
Thanks
Basit

Answers (2)