I have a data grid view in one windows form named \"GridViewForm\". When the user search for the text from the search box from another window form named \"FindForm\", I want to
Well you could set the cell's background color with a different color to highlight all the matches, and select only the cell corresponding to the current match:
Dim searchIndex = 0
AccountsDataGridView.ClearSelection()
For Each row As DataGridViewRow In AccountsDataGridView.Rows
For each cell As DataGridViewCell in row.Cells
If CStr(cell.Value).Contains(SearchTextBox.Text, StringComparison.OrdinalIgnoreCase) Then
If searchIndex = m_CurrentSearchIndex Then
'This is the cell we want to select
cell.Selected = True
End If
'Yellow background for all matches
cell.Style.BackColor = Color.Yellow
searchIndex += 1
End If
Next
Next
If m_CurrentSearchIndex has a value of 0, it would select the first match, second match for a value of 1, etc.