Selecting a DataGridView Row that is not in View

  • Thread starter Thread starter Patrick
  • Start date Start date
P

Patrick

I have a data-grid view already populated.

This is what should happen when I click a button
1) Detect selected rows
2) Calls SP to bulk update a flag on selected row
3) Refresh data-grid
4) Data-grid "scroll back" to the row user was on before

I tried the following which works only if the row selected is on the first
page (i.e., visible without having to page down on the DataGridView.
myDataGridView.Rows[indexRow].Selected =true;
myDataGridView.Rows[indexRow].Visible = true;

What code should I use to handle rows selected which are not in view without
page downing.
 
I have a data-grid view already populated.

This is what should happen when I click a button
1) Detect selected rows
2) Calls SP to bulk update a flag on selected row
3) Refresh data-grid
4) Data-grid "scroll back" to the row user was on before

I tried the following which works only if the row selected is on the first
page (i.e., visible without having to page down on the DataGridView.
myDataGridView.Rows[indexRow].Selected =true;
myDataGridView.Rows[indexRow].Visible = true;

What code should I use to handle rows selected which are not in view without
page downing.

I'm not sure what you are attempting to do with that code fragment.
Why do you care if selected rows are in view?

If you are trying to do #4, you can use the FirstDisplayedCell
property.
 
Back
Top