如何在 Visualbasic.net 中添加 Vscroll 控件到窗体?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5817251/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to add Vscroll control to form in Visualbasic.net?
提问by Islam Muntasser
i need to add vscroll control to a form in VB.net and i need to use it to scroll the form where i need to add more controls in the form where the size of form not able me to add them ?
我需要将 vscroll 控件添加到 VB.net 中的表单,我需要使用它来滚动表单,我需要在表单中添加更多控件的表单中,表单的大小无法添加它们?
and i need to know how to make the scrolling to show more controls in the form ?
我需要知道如何进行滚动以在表单中显示更多控件?
thank you in advance
先感谢您
回答by darda
I think you want the form's AutoScrollproperty.
我想你想要表单的AutoScroll属性。
回答by Cody Gray
"Vscroll" is not the name of a control, but I assume it's an abbreviation for vertical scrollbar.
“Vscroll”不是控件的名称,但我认为它是vertical scrollbar的缩写。
In that case, you can simply add a VScrollBarcontrolto your form. You'll find it in the Toolbox under the "All Windows Forms" category. Unfortunately, you'll have to wire it up yourself. By default, the control won't do anything exciting.
在这种情况下,您只需在表单中添加一个VScrollBar控件即可。您可以在“所有 Windows 窗体”类别下的工具箱中找到它。不幸的是,您必须自己接线。默认情况下,控件不会做任何令人兴奋的事情。
HScrolland VScrollare also properties of any control that derives from ScrollableControl, such as a form and all panel controls. By setting one or both of these properties to "True", you can cause a horizontal or vertical scroll bar to appear, no additional control required.
HScroll并且VScroll也是从 派生的任何控件的属性ScrollableControl,例如窗体和所有面板控件。通过将这些属性中的一个或两个设置为“True”,您可以使水平或垂直滚动条出现,不需要额外的控制。
But before you embark too far down this road, I should caution you against reinventing the wheel. Controls that derive from ScrollableControlalsohave an AutoScrollpropertythat will cause scrollbars to appear automatically when the content they contain does not fit in the viewable area of the control. Simply set this property to "True", and let the magic happen. It maintains the visibility of the scrollbars automatically, eliminating the need to use a separate control or set the HScrollor VScrollproperties.
但在你走上这条路之前,我应该告诫你不要重新发明轮子。派生自的控件ScrollableControl也有一个AutoScroll属性,当它们包含的内容不适合控件的可视区域时,该属性将导致滚动条自动出现。只需将此属性设置为“True”,然后让魔法发生。它自动保持滚动条的可见性,无需使用单独的控件或设置HScroll或VScroll属性。
If I were you, I would add either a TableLayoutPanelor a FlowLayoutPanelcontrol to my form, and then place all of the other controls I wanted to add insideof the panel. Then, I would just turn on the AutoScrollproperty and let the control maintain everything automatically.
如果我是你,我会在我的表单中添加一个TableLayoutPanel或一个FlowLayoutPanel控件,然后将我想添加的所有其他控件放在面板内。然后,我只需打开该AutoScroll属性并让控件自动维护所有内容。

