Autoscroll Does Not Work in Child UserControl

I have a UserControl Parent that contains Child controls. I would like my Parent control to execute automatically when it is too small for Child . To get Autoscroll, I set AutoScroll to True in my Parent and made sure that Child is big enough so that I can resize Parent to be smaller than it. My Parent contained inside a Form and bound to all four edges. The problem is that I cannot get the scroll bars to appear at runtime.

I cannot display a control without a form, of course, if it was not in Designer. In the Visual Studio 2008 designer, the Parent Autoscrol constructor is fine: I can resize the control, and whenever its Child partially hidden by the Parent edge, scroll bars appear. However, when I view the control in Form Designer or at run time, the scroll bars are not displayed, regardless of how I resize the Parent .

This seems like a mistake, but I feel more like I'm missing something obvious. Something about being a child of Form seems to be hampering AutoScroll.

+4
source share
3 answers

Try setting dock = none. It seems that the problem is with the docking and scrollbars. In my own tests with AutoScroll = true: if Dock = Fill, then there are no scroll bars, if Dock = Top, then a vertical scroll bar if Dock = Left, and then a horizontal scroll bar if Dock = None, then scroll bars .

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

+1
source

Did you try to place the panel docked inside your parent control using the user control inside the panel?

0
source

I had a similar problem .... with my child controls that need to be created dynamically and then to enable the parent element for the autoscroll parameter.

The problem was that I installed the child panel on the left. When we are not a docking station, then the parent worked successfully ...

0
source

Source: https://habr.com/ru/post/1332542/


All Articles