I need to force the DataGridView
to show the selected row
.
In short, I have a textbox
that changes the DGV
selection based on what is typed into the textbox
. When this happens, the selection changes to the matching row
.
Unfortunately if the selected row
is out of the view, I have to manually scroll down to find the selection. Does anyone know how to force the DGV
to show the selected row
?
Thanks!
To get the selected rows in a DataGridView controlUse the SelectedRows property. To enable users to select rows, you must set the SelectionMode property to FullRowSelect or RowHeaderSelect.
You can set:
dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.SelectedRows[0].Index;
Here is the MSDN documentation on this property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With