prevent duplicate RECORDS datagridview

md110

Member
Joined
Oct 14, 2008
Messages
11
Programming Experience
1-3
hai
how to prevent duplicate RECORDS in datagridview cell vb.net
please help me
 
Can you explain more?
 
i have 3 columns in my datagridview
how to prevent duplicate values in one column for each rows

this code
VB.NET:
 For i As Integer = 0 To DG.Rows.Count - 2
                If i <> e.RowIndex Then
                    If DG("col_id", e.RowIndex).Value = DG("col_id", i).Value Then
                        MsgBox("duplicate")
                        e.Cancel = True
                        DG("col_id", e.RowIndex).ErrorText = "not duplicate"
                        DG.CurrentCell = DG.CurrentRow.Cells(0)
                        DG.EndEdit()
                        Exit For

                    Else
                        e.Cancel = False
                        DG("col_id", e.RowIndex).ErrorText = ""
                    End If
                End If
            Next i
please beter code tahan my code
 
Last edited:
Back
Top