i have two datagridview in a form datagridview1 and datagridview2 and one button which named delete. Both datagridview has some rows where first column id and second column name are same. I want if i delete a row from datagridview1 then it should automatically delete matching row in datagridview2. i do not know how to do this? please tell me how to do this?
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
For Each rw As DataGridViewRow In DataGridView2.SelectedRows
Dim x As String
x = rw.Cells(0).Value
For Each row As DataGridViewRow In DataGridView1.SelectedRows
DataGridView1.Rows.Remove(row)
If row.Cells(0).Value = x Then
DataGridView2.Rows.Remove(row)
End If
Next
Next
End Sub