Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make the DataGridView show the selected row?

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!

like image 753
kereberos Avatar asked Dec 08 '11 21:12

kereberos


People also ask

How to get the Selected row in DataGridView?

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.


1 Answers

You can set:

dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.SelectedRows[0].Index; 

Here is the MSDN documentation on this property.

like image 173
competent_tech Avatar answered Sep 28 '22 23:09

competent_tech