Reputation: 39
I have 2 form pages, the first page(default page) is including my data gridview, I can show lot of data in my data gridview.
when I double click on an Item in my data gridview for example (row = 1000) the second form will appear which is for editing,
when I press Edit button in the second page the First page will appear ,
how can I handle -->** that the index of Gridview be on the row which I selected for editing (row = 1000)
Upvotes: 0
Views: 592
Reputation: 5636
Try for FirstDisplayedScrollingRowIndex property of grid view like
dataGridView1.FirstDisplayedScrollingRowIndex = dataGridView1.SelectedRows[0].Index;
This will select your one particular row. For more details Visit MSDN
Solution for argumentOtOfRangeException error
For solving this problem make sure that all the rows of datagridview have the same width and height otherwise the
FirstDisplayedScrollingRowIndex
causing problem.
Hope it works.
Upvotes: 2
Reputation: 2071
Here is the code to directly scroll to you desired location
// index is your poistion ie 1000
dataGridView1.FirstDisplayedScrollingRowIndex = index;
dataGridView1.Refresh();
dataGrid.CurrentCell = dataGrid.Rows[index].Cells[0];
dataGrid.Rows[index].Selected = true;
Upvotes: 0