开发者

Auto Scroll on All Sides

I have a panel with autoscroll 开发者_如何学Pythonset to true. In this panel I have a graphical control representing a drawing canvas. Zooming in to the canvas means that the graphical control increases in size and eventually exceeding the containng control.

My problem is that there is no autoscroll when moving things to negative coordinates. I would like to have my graphical control to grow on all sides and keep its center in view and get scrollbars that allow scrolling both left/right and up/down. As far as I can see I will only get scrolling down and right.


You just have to adjust the panel's AutoScrollPosition accordingly.

To set the position to the middle of your graphical control (whatever that is), try this on your panel:

panel1.AutoScroll = false;
panel1.AutoScrollMinSize = pictureBox1.Size;
panel1.AutoScrollPosition = new Point((panel1.AutoScrollMinSize.Width - panel1.HorizontalScroll.LargeChange) / 2,
                                      (panel1.AutoScrollMinSize.Height - panel1.VerticalScroll.LargeChange) / 2);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜