Scrolling in DataGridView in Visual Studio 2005




I edit a cell in a DataGridView, and then would move to another cell
in the DataGridView using mouse. Then the DataGridView as of now does
scroll down to the last visited cell. But when I try to edit the same
last visited cell, focus gets shifted to the first few visible rows as
per the dimensions set for the DataGridView. To be exact it goes to
the cell in the first row, and the same column.

If I can say it this way, I would like to see same number of Rows
visible at the top, after scrolling down to the selected row / cell
using mouse on the GridView and even before the scrolling was done.

I have tried out many weird ways to do it, but none of them does the
job for me. A thing to add, I refresh my DataGridView every time, I do
a cell value change, which would be followed by cell validating event
and cell Error Check. I get the last recent edited cell in a moment,
but scrolling to the same seems to be a problem for me. I tried
capturing every other event here, but they do not give any solution.

If any of you have worked on the same, let me know any ideas you have
regarding the same.


In DataGrid of VS 2005 and VS 2003, we have a protected method
GridVScrolled, which can be over written in its derived class and then
we can use this to scroll to a particular row in the DataGrid. Refer
to: for more
information on the same implementation.

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