This project is read-only.

Scroll to the middle

Apr 21, 2009 at 5:12 PM

I would like to scroll my grid so that the middle of the grid is in the centre of the screen.  I can see from the code that there are methods to scroll pageup/down, specific cells into view etc, but nothing to do what I really need.

What I'd really like to do is just call the CustomScrollPosition as below

                Point pt = new Point();
                int minVScroll = grid.MinimumVScroll;
                int maxVScroll = grid.MaximumVScroll;
                int minHScroll = grid.MinimumVScroll;
                int maxHScroll = grid.MaximumVScroll;

                pt.X = (maxHScroll - minHScroll) / 2;
                pt.Y = (maxVScroll - minVScroll) / 2;
                grid.CustomScrollPosition = pt;

However MinimumVScroll are all protected.

I have tried to get the max and min values from methods such as grid.HorizontalScroll.Minimum but these always give me 0 and 100 so I assume that they are not implemented properly yet.

Is there something that I have missed that will let me do this?

May 1, 2009 at 5:02 PM
Hi again,

Any thoughts on this?  I've fixed most of my other problems, but this one is about to come round again.


May 5, 2009 at 9:23 AM
You can create your own class that inherit from Grid (or whatever grid class you are using) and implement method that center scroll bars to middle as you can access protected methods than.