I searched quite a lot for this answer, but no one was able to help me. I tried to use or even see if applicable .Focus(), as other websites suggested it, but it is not. I would just like DataGridViewHistoryData.
to go to the selected line. This, of course, is true, but he will not scroll it when the number of elements fills the grid. Could there be a parameter that is missing in the grid?
Here is my code:
Private Sub HistorySearch_TextChanged(sender As Object, e As EventArgs) Handles HistorySearch.TextChanged
Try
If HistorySearch.Text.ToString <> "" Then
For Each HistoryRow As DataGridViewRow In HistoryData.Rows
HistoryData.ClearSelection()
For Each HistoryCell As DataGridViewCell In HistoryRow.Cells
If HistoryCell.Value.ToString.StartsWith(HistorySearch.Text.ToString) Then
HistoryRow.Selected = True
Dim i As Integer = HistoryData.CurrentRow.Index()
Else
HistoryRow.Selected = False
End If
If HistoryCell.Value.ToString.Contains(HistorySearch.Text.ToString) Then
HistoryRow.Selected = True
Dim i As Integer = HistoryData.CurrentRow.Index()
Return
Else
HistoryRow.Selected = False
End If
Next
Next
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
source
share