Software Developer, Equity Analyst, 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
This entry was posted by Ray Tawil on May 12, 2010 at 7:12 pm, and is filed under Visual Basic.Net. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site.
Leave a Reply
You must be logged in to post a comment.