开发者

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.


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.


Have you tried placing a Panel docked inside your parent control with your user control inside the Panel?


I had the similar issue.... with my child controls to be created dynamically and then to enable the parent for autoscroll option.

The issue was because i had docked the child panel to left. When we dont dock then parent was working successfully...

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜