I'm working with a Winforms grid that may, or may not, have paging set. I need to open a popup editor and edit a record. After I save, I need to pull the data from the database again (other people may have made changes on other workstations) and want the grid to return to the position it was at when the use edit the record.
Given the layout below where only Rows C, D, and E are visible, if the user edits Row D and then saves, I want the grid to look exactly like this with D as the current row.
Row A
Row B
----------
Row C
Row D (edited row)
Row E
----------
Row F
Here is what I tried but its not working as I expected.
int currentRow = gvMemos.CurrentCell.RowIndex;
int scrollPos = gvMemos.TableElement.VScrollBar.Value;
//Do something
if (scrollPos > 0)
gvMemos.TableElement.VScrollBar.Value = scrollPos;
if (currentRow > 0)
{
gvMemos.TableElement.ScrollToRow(currentRow);
gvMemos.CurrentRow = gvMemos.Rows[currentRow];
//gvMemos.CurrentRow.EnsureVisible();
}Thanks
Carl
