Hi @StewartBW ,
You can use LINQ to make the code more concise and potentially more efficient.
DataGridView.ClearSelection()
Dim searchText As String = SearchTextBoxDropDown.Text.ToLowerInvariant()
Dim matchingRows = (From row As DataGridViewRow In DataGridView.Rows
Where row.Cells(0).Value.ToString().ToLowerInvariant().Contains(searchText)
Select row.Index).ToList()
For Each rowIndex As Integer In matchingRows
DataGridView.Rows(rowIndex).Selected = True
Next
If matchingRows.Count > 0 Then
DataGridView.FirstDisplayedScrollingRowIndex = matchingRows(0)
End If
Best Regards.
Jiachen Li
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.