Software Engineer, Equity Strategist, Polymath.
Searching through all columns in datagridview
Assuming you are searching for the name John, the following procedure will search all existing columns regardless
Dim x As Integer = 0
While x < DataGridView1.Rows.Count
Dim y As Integer = 0
While y < DataGridView1.Rows(x).Cells.Count
Dim c As DataGridViewCell = DataGridView1.Rows(x).Cells(y)
If Not c.Value Is DBNull.Value Or Nothing Then
If CType(c.Value, String) = "John" Then
MessageBox.Show("Found!")
End If
End If
System.Math.Min(System.Threading.Interlocked.Increment(y), y - 1)
End While
System.Math.Min(System.Threading.Interlocked.Increment(x), x - 1)
End While
MessageBox.Show("Search complete!")
End Sub
Leave a Reply
You must be logged in to post a comment.