Selected row always visible in datagridview research
-
I want to perform a search in a DataGridView. The search command is working, but I have a problem: a row always remains visible in the DataGridView even if it does not correspond to the search criteria. This row is always the last selected one. I have tried using 'ClearSelection,' and no rows are selected/highlighted, but the problem persists—the same row is still visible. this is my code :
Private Sub TxtboxReserch_TextChanged(sender As Object, e As EventArgs) Handles TxtboxReserch.TextChanged
If TxtboxReserch.Text = "" Then
For i = 0 To DataGridView1.RowCount - 1
DataGridView1.Rows(i).Visible = True
Next
Else
DataGridView1.ClearSelection()
For i = 0 To DataGridView1.RowCount - 1
Try
DataGridView1.Rows(i).Visible = (DataGridView1.Rows(i).Cells(1).Value Like "*" + TxtboxReserch.Text + "*")Catch ex As Exception End Try Next End If
End Sub
-
I want to perform a search in a DataGridView. The search command is working, but I have a problem: a row always remains visible in the DataGridView even if it does not correspond to the search criteria. This row is always the last selected one. I have tried using 'ClearSelection,' and no rows are selected/highlighted, but the problem persists—the same row is still visible. this is my code :
Private Sub TxtboxReserch_TextChanged(sender As Object, e As EventArgs) Handles TxtboxReserch.TextChanged
If TxtboxReserch.Text = "" Then
For i = 0 To DataGridView1.RowCount - 1
DataGridView1.Rows(i).Visible = True
Next
Else
DataGridView1.ClearSelection()
For i = 0 To DataGridView1.RowCount - 1
Try
DataGridView1.Rows(i).Visible = (DataGridView1.Rows(i).Cells(1).Value Like "*" + TxtboxReserch.Text + "*")Catch ex As Exception End Try Next End If
End Sub