Reputation: 88
In my program i have a panel of 1000 by 1500 pixels, in that panel is a panel of 4000 by 10000 pixels which I can scroll through. Now this panel starts like in the left (example in the picture) but i was wondering if I could make it start like in the right example. And is it possible to change the 0,0 point of the Panel (picture in the link)
Im using a derived Panel
class BufferedPanel : Panel
{
public BufferedPanel()
{
this.DoubleBuffered = true;
this.ResizeRedraw = true;
}
}
Upvotes: 2
Views: 1589
Reputation: 125312
You need to set the initial scroll position for the outer auto-scroll panel. To do so you can set AutoScrollPosition
property of the outer panel. You should do it after the form is shown:
protected override void OnShown(EventArgs e)
{
base.OnShown(e);
panel1.AutoScrollPosition = new Point(0, 1250);
}
Upvotes: 1
Reputation: 383
Please try to add this to the panel constructor:
this.Anchor = System.Windows.Forms.AnchorStyles.Left;
Upvotes: 0
Reputation: 26
You can set the Location property of your new Panel.
Panel.Location = New Point(OriginalPanel.Width/2 - Panel.Size.Width/2, OriginalPanel.Height/2 - Panel.Size.Height/2);
Upvotes: 0