Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autoscroll Doesn't work in Child UserControl

I have a UserControl Parent that contains Child controls. I would like my Parent control to Autoscroll when it is too small for its Child. To get Autoscroll, I've set AutoScroll to True in my Parent, and ensured that the Child is large enough that I can resize the Parent to be smaller than it. My Parent is contained inside a Form and is anchored to all four edges. The problem is that I cannot seem to get the scrollbars to appear during runtime.

I cannot display a control without a form, of course, unless it's in Designer. In Visual Studio 2008 Designer, the Parent Autoscrolls perfectly: I can resize the control, and whenever its Child is partially hidden by the edge of Parent, the scrollbars appear. However, when viewing the control in either the Form's designer or during runtime, the scrollbars do not appear, no matter how I resize the Parent.

This seems like a bug, but feels more like I'm missing something obvious. Something about being a child of the Form seems to be inhibiting the AutoScroll.

like image 725
Nathan Avatar asked Dec 17 '10 19:12

Nathan


1 Answers

Try setting dock=none. There appears to be an issue with docking and scroll bars. In my own tests with AutoScroll=true: if Dock=Fill then no scrollbars, if Dock=Top then vertical scrollbar, if Dock=Left then horizontal scrollbar, if Dock=None then both scrollbars.

In the end I set Dock=None for my user controls and scrollbars appeared as expected.

like image 72
mcdon Avatar answered Oct 05 '22 23:10

mcdon