View DataGridView's Selected Row

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!
 
P

Pavel Minaev

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.
 
J

jp2msft

FYI: I found what I originally did this with:

I set the DGV.CurrentCell.

Maybe this will aid others.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top