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

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

Recommended Answers

All 7 Replies

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.

no I am not using any database.. just in datagridview..

How is the data getting into the DataGridView? Where does the data come from?

the data came from the services..

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
            Next
        Next
    End Sub

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

thanks artemix22 problem solved.. Godbless everyone! :)

you're welcome

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.