how to add Vscroll control to form in Visualbasic.

2019-08-30 19:11发布

问题:

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 ?

and i need to know how to make the scrolling to show more controls in the form ?

thank you in advance

回答1:

I think you want the form's AutoScroll property.



回答2:

"Vscroll" is not the name of a control, but I assume it's an abbreviation for vertical scrollbar.

In that case, you can simply add a VScrollBar control to 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.

HScroll and VScroll are 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.

But before you embark too far down this road, I should caution you against reinventing the wheel. Controls that derive from ScrollableControl also have an AutoScroll property that 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 HScroll or VScroll properties.

If I were you, I would add either a TableLayoutPanel or a FlowLayoutPanel control to my form, and then place all of the other controls I wanted to add inside of the panel. Then, I would just turn on the AutoScroll property and let the control maintain everything automatically.