I programmatically edit my datagridview cell values. I use the vertical scrollbar to find the row I want to edit, select the row then click an edit button that takes me to another form where changes to the record are made. I then click a button which saves the changes and returns me to the datagridview form. No problems here.

When I return to the grid, the records are displayed with the first record at the top of the grid. That is, the vertical scroll bar has repositioned itself to the very top.

Is it possible for the datagridview to "remember" the position of the vertical scroll bar so that when I am returned to the grid, the rows displayed are the same as when I left?

Any ideas about how to go about this would be greatly appreciated.

Recommended Answers

All 5 Replies

See if this helps.

With DataGridView1
            Static iTopRow As Integer
            iTopRow = .FirstDisplayedScrollingRowIndex '// get Top row.
            Form2.ShowDialog()'// Form that edits record.
            .FirstDisplayedScrollingRowIndex = iTopRow '// set Top row.
        End With

Excactly what I was after! Thankyou, it works a treat.

Thank you very much, it helps me a lot.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.