bobbyforhire
Technical User
I have a self populated datagridview getting it's data from a csv. I am trying to add a search field to find text in a coloum and then goto the colum then goto the next item if any. So far i've been able to search for the item and it finds it and goes to it, but i don't know how to tell it to goto the next item if any insead of just re-finding the first item.
here is my current code for the search.
For i As Integer = 0 To Me.DataGridView1.Rows.Count - 1
For j As Integer = 0 To Me.DataGridView1.Rows(i).Cells.Count - 1
If Me.DataGridView1.Item(j, i).Value IsNot Nothing Then
If Me.DataGridView1.Item(j, i).Value.ToString.Contains(TextBox1.Text) Then
' CType(Me.DataGridView1.Item(j, i), DataGridViewCell).Style.BackColor = Color.Blue
Me.DataGridView1.ClearSelection()
Me.DataGridView1.CurrentCell = Me.DataGridView1.Item(j, i)
End If
End If
Next
Next
here is my current code for the search.
For i As Integer = 0 To Me.DataGridView1.Rows.Count - 1
For j As Integer = 0 To Me.DataGridView1.Rows(i).Cells.Count - 1
If Me.DataGridView1.Item(j, i).Value IsNot Nothing Then
If Me.DataGridView1.Item(j, i).Value.ToString.Contains(TextBox1.Text) Then
' CType(Me.DataGridView1.Item(j, i), DataGridViewCell).Style.BackColor = Color.Blue
Me.DataGridView1.ClearSelection()
Me.DataGridView1.CurrentCell = Me.DataGridView1.Item(j, i)
End If
End If
Next
Next