Scrollable Form in c#, AutoScroll=true doesn't work

后端 未结 3 1512
我在风中等你
我在风中等你 2020-12-19 07:26

What are the rules which I have to respect to make the Form scrollable...

I simple set the Property AutoScroll to true. I also tried while Auto Sc

3条回答
  •  -上瘾入骨i
    2020-12-19 08:20

    The content controls the scrolling. The scrollbars do not appear unless they are needed. Usually, there is a property available that you can set to force them to be visible always, and simply disabled until needed.

    The AutoScroll property must be true, as you have already found. But then the content of the scrollable control must force the parent control to display the scrollbars. This part is up to how the controls are embedded within the parent.

    Try these two experiments:

    1. Place a Panel on your form and dock it to Fill. Set the AutoScroll property of the Panel to true. Into that panel, place a TextBox and set it to dock as Fill as well. Also set MultiLine to true. Run the application, and you will notice that the size of both is simply using the available space...no scrolling can occur because neither the Panel, nor its TextBox become larger than the space they occupy.

    2. Perform the same steps as in #1, but this time, do not dock the TextBox. Instead, set it to a large size, something that you know will be larger than the amount of Panel that is visible. Running the application should now produce a scrolling Panel.

    Hopefully this little test helps to demonstrate what is controlling the scroll on a form.

提交回复
热议问题