mardi 21 mai 2019

Checking if datagridview already exist in another datagridview before inserting using checkbox

i have two datagridview and i am trying to insert value in datagridview1 to datagridview2 using checkbox on button click.

For i As Integer = DataGridView1.Rows.Count - 1 To 0 Step -1

        Dim c As Boolean
        c = DataGridView1.Rows(i).Cells(0).Value

        If c = True Then
            With DataGridView1.Rows(i)
                DataGridView2.Rows.Insert(0, .Cells(0).Value, .Cells(1).Value, .Cells(2).Value, .Cells(3).Value, .Cells(4).Value, .Cells(5).Value)
            End With
        End If

    Next

My code will insert the data everytime i insert it. I want to prevent inserting the same data on datagridview2. Thank you so much.




Aucun commentaire:

Enregistrer un commentaire