I have a panel where I dynamically add custom controls to it. If controls go out of the panels bounds, Horizontal/Vertical scrollbars automatically shows (AutoScroll == true) and scrollbars will follow the control via the following code:
if(panelDiagram.VerticalScroll.Visible || panelDiagram.HorizontalScroll.Visible) {
panelDiagram.ScrollControlIntoView(tempNode);
}
This way, while moving the tempNode around, scrollbars will follow it.
Is there any way to preserve the state of the scrollbars when I load everything again from the database? I tried a lot of things like ScrollControlIntoView(lastAddedControl) but nothing is working. Maybe I have to turn off AutoScroll and manage everything by my hand?
Panelis derived fromScrollableControlwhich exposes a few properties you might find useful:AutoScrollPositionVerticalScrollHorizontalScrollIt looks like
autoScrollPositionis what you’re after; it’s aPointinstance that contains the current X and Y scroll coordinates for each scrollbar.Xwill be zero if you’re only doing vertical scrolling.Save it like so: