Scrollable Form in c#,AutoScroll = true不起作用 [英] Scrollable Form in c#, AutoScroll=true doesn't work
问题描述
我简单地设置Property 也许使用 内容控制滚动。除非需要滚动条,否则不会显示滚动条。通常情况下,您可以设置一个属性来强制它们始终可见,并且直到需要时才将其禁用。 AutoScroll $> c $ c>为真。
我也尝试了 Auto Scroll
为true,将 AutoSize
设置为true / false,但没有这些工作...也试图把面板和所有组件添加在那里......仍然没有...
V或HScrollBar 可以提供帮助,但我真的不知道如何将它与表单链接...
form.AutoScroll = true;
formMainLayout.AutoScroll = true;
rootPanel.AutoScroll = true;
$ b AutoScroll
true
,因为您已经找到了。但是,那么可滚动控件的内容必须强制父控件显示滚动条。这部分取决于如何将控件嵌入到父代中。
试试这两个实验:
-
在您的表单上放置一个
Panel
,并将其放置到填充
。将面板的AutoScroll
属性设置为true
。在该面板中,放置一个TextBox
,并将它设置为停靠为填充
。还要将MultiLine
设置为true
。运行该应用程序,您会注意到两者的大小仅仅是使用可用空间...不会发生滚动,因为Panel
和它的TextBox
变得比他们占用的空间大。 执行与#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:
Place a
Panel
on your form and dock it toFill
. Set theAutoScroll
property of the Panel totrue
. Into that panel, place aTextBox
and set it to dock asFill
as well. Also setMultiLine
totrue
. Run the application, and you will notice that the size of both is simply using the available space...no scrolling can occur because neither thePanel
, nor itsTextBox
become larger than the space they occupy.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 ofPanel
that is visible. Running the application should now produce a scrollingPanel
.
Hopefully this little test helps to demonstrate what is controlling the scroll on a form.
这篇关于Scrollable Form in c#,AutoScroll = true不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!