Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim str As String = TextBox1.Text
Try
If Me.TextBox1.Text.Trim = "" Then
MsgBox("Please fill Searching Index")
Exit Sub
Else
For i As Integer = 0 To Me.DataGridView1.Rows.Count - 2
For j As Integer = 0 To Me.DataGridView1.Rows(i).Cells.Count - 1
If DataGridView1.Item(j, i).Value.ToString().ToLower.StartsWith(str.ToLower) Then
DataGridView1.Rows(i).Selected = True
DataGridView1.CurrentCell = DataGridView1.Rows(i).Cells(j)
MsgBox("Found matched item")
End If
Next
Next i
End If
Catch abc As Exception
MsgBox("Not Found")
End Try
End Sub
Nguồn: Sharecode.vn