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!


You can set:

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

Here is the MSDN documentation on this property.


This one scrolls to the selected row without put it on top.

dataGridView1.CurrentCell = dataGridView1.Rows[index].Cells[0];