I have a datagridview, In a textboxcolumn should have a unique data..

i want in the cardnumber not to be the same.. Need trappings

Attachments zz.png 6.11 KB

Are you using any database? If yes Then have a unique column in DB and get the values from DB anad attach to grid view column.

Private Sub DataGridView1_Validated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGridView1.Validated
        For i As Integer = 0 To DataGridView1.Rows.Count - 1
            For j As Integer = i + 1 To DataGridView1.Rows.Count - 1
                If DataGridView1.Rows(i).Cells(1).Value = DataGridView1.Rows(j).Cells(1).Value Then
                    MsgBox("Duplicate: " & DataGridView1.Rows(j).Cells(1).Value)
                    Exit Sub
                End If
    End Sub

i think it will give you a "duplicate" message if column cardNumber has same value. try it

This question has already been answered. Start a new discussion instead.