View DataGridView's Selected Row

  • Thread starter Thread starter jp2msft
  • Start date Start date
J

jp2msft

I've got a TreeView (TV) control that contains a list of grouped indexes.

I also have a DataGridView (DGV) control that contains all of the details
for a given index (along with the actual index).

Whenever a TV Node is selected, I go through the DGV Rows to find the
corresponding index, and select that DGV Row.

This works fine.

If I have so many rows in my DGV that they scroll off the form, the row
might be selected, but it is not scrolled into view.

How would I make sure the first Selected Row is visible in the DGV control?

I had this feature working before in this project; however, it has been
modified and changed, and it does not do it now. I don't remember what the
method or property was called, so I don't know what to search for. ...Ugh! So
frusterating!
 
jp2msft said:
I've got a TreeView (TV) control that contains a list of grouped indexes.

I also have a DataGridView (DGV) control that contains all of the details
for a given index (along with the actual index).

Whenever a TV Node is selected, I go through the DGV Rows to find the
corresponding index, and select that DGV Row.

This works fine.

If I have so many rows in my DGV that they scroll off the form, the row
might be selected, but it is not scrolled into view.

How would I make sure the first Selected Row is visible in the DGV
control?

Have a look at DataGridView.FirstDisplayedScrollingRowIndex property. Set it
as needed.
 
FYI: I found what I originally did this with:

I set the DGV.CurrentCell.

Maybe this will aid others.
 
Back
Top