Quantcast
Channel: Windows Forms Data Controls and Databinding forum
Viewing all articles
Browse latest Browse all 2535

delete matching rows

$
0
0

I am using two datagridviews ad I am trying to delete any duplicate entries from datagrid view 2 that appear in datagrid 1 so that I can merge the remaining items into datagrid 1 code :

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim dvddata As Integer

        If DataGridView1.RowCount <> 0 And DataGridView2.RowCount <> 0 Then
            DVDDATA = 0
            For merge = 0 To DataGridView2.RowCount - 1
                If DataGridView1.Item(1, dvddata).Value = DataGridView2.Item(1, merge).Value Then
                    DataGridView1.Rows.RemoveAt(dvddata)
                    dvddata = dvddata + 1
                End If
            Next
        Else
            MsgBox("No Data To Compare", MsgBoxStyle.Exclamation)
        End If
    End Sub


Viewing all articles
Browse latest Browse all 2535

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>