Autoscroll jump when removing a control at run-time

  • Thread starter Thread starter Predrag Rakic
  • Start date Start date
P

Predrag Rakic

I have a form with autoscroll on, and in run-time a number of user controls added to the form, so that the vertical scroll bar appears. When I try to remove a control (in a on mouse down event handler) that is e.g. near the bottom of the form, the control is removed but the vertical scroll bar (and the visibly portion of the screen) unexpectedly jumps to the top of the form. Can I in some way tell the autoscroll to stay where it was prior control removal?

Sincerelly,

Predrag Rakic
 
You should be able to set the AutoScrollMinSize to a specific value that
ensures that the scrollbars remain in position. When scrollbars are shown or
hidden however, the client area is usually moved or recalculated.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Back
Top