I have a DataGridView that contains a few columns of data.
Is there a way to check a column for a value before i add a new row, just to make sure i dont put dupes in it?
Printable View
I have a DataGridView that contains a few columns of data.
Is there a way to check a column for a value before i add a new row, just to make sure i dont put dupes in it?
try this:
vb Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim found = From row As DataGridViewRow In DataGridView1.Rows.Cast(Of DataGridViewRow)() _ Where row.Cells(1).Value.ToString = "value to find" _ Select True MsgBox(found.FirstOrDefault) End Sub
This is how I search value in a datagridview:
For i = 0 To DataGridView1.RowCount - 1
If DataGridView1.Rows(i).Cells("Column1").Value = "Value" Then
MsgBox("x")
End If
Next