Scrollable Form in c#,AutoScroll = true不起作用 [英] Scrollable Form in c#, AutoScroll=true doesn't work

查看:289
本文介绍了Scrollable Form in c#,AutoScroll = true不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我简单地设置Property AutoScroll c $ c>为真。
我也尝试了 Auto Scroll 为true,将 AutoSize 设置为true / false,但没有这些工作...也试图把面板和所有组件添加在那里......仍然没有...

也许使用 V或HScrollBar 可以提供帮助,但我真的不知道如何将它与表单链接...

  form.AutoScroll = true; 
formMainLayout.AutoScroll = true;
rootPanel.AutoScroll = true;


解决方案

内容控制滚动。除非需要滚动条,否则不会显示滚动条。通常情况下,您可以设置一个属性来强制它们始终可见,并且直到需要时才将其禁用。


$ b

AutoScroll

code>属性必须为 true ,因为您已经找到了。但是,那么可滚动控件的内容必须强制父控件显示滚动条。这部分取决于如何将控件嵌入到父代中。



试试这两个实验:


  1. 在您的表单上放置一个 Panel ,并将其放置到填充。将面板的 AutoScroll 属性设置为 true 。在该面板中,放置一个 TextBox ,并将它设置为停靠为填充。还要将 MultiLine 设置为 true 。运行该应用程序,您会注意到两者的大小仅仅是使用可用空间...不会发生滚动,因为 Panel 和它的 TextBox 变得比他们占用的空间大。

  2. 执行与#1中相同的步骤,但是这次不要停靠 TextBox 。相反,将其设置为较大的尺寸,您知道的尺寸将大于可见的 Panel 的数量。运行应用程序现在应该产生滚动面板


希望这个小测试有助于展示什么是控制窗体上的滚动。


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 Scroll is true, to set AutoSize to true/false, but none of these worked... also tried to put Panel and added all components in there... still nothing...

Maybe using V or HScrollBar can help, but i really don't know how to link it with the Form...

form.AutoScroll = true;
formMainLayout.AutoScroll = true;
rootPanel.AutoScroll = true;

解决方案

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.

这篇关于Scrollable Form in c#,AutoScroll = true不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆