Home » VB.NET ScrollBars Control

VB.NET ScrollBars Control

by Online Tutorials Library

VB.NET ScrollBars Control

A ScrollBar control is used to create and display vertical and horizontal scroll bars on the Windows form. It is used when we have large information in a form, and we are unable to see all the data. Therefore, we used VB.NET ScrollBar control. Generally, ScrollBar is of two types: HScrollBar for displaying scroll bars and VScrollBar for displaying Vertical Scroll bars.

Let’s create a ScrollBar control in the VB.NET Windows form using the following steps.

Step 1: The first step is to drag the HScrollBar and VScrollBar control from the toolbox and drop it on to the form.

VB.NET ScrollBars Control

Step 2: Once the ScrollBar is added to the form, we can set various properties of the ScrollBar by clicking on the HScrollBar and VScrollBar control.

Properties of the ScrollBar Control

There are following properties of the VB.NET ScrollBar control.

Property Description
BackColor The BackColor property is used to set the back color of the scroll bar.
Maximum It is used to set or get the maximum value of the Scroll Bar control. By default, it is 100.
Minimum It is used to get or set the minimum value of the Scroll bar control. By default, it is 0.
SmallChange It is used to obtain or set a value that will be added or subtracted from the property of the scroll bar control when the scroll bar is moved a short distance.
AutoSize As the name suggests, the AutoSize property is used to get or set a value representing whether the scroll bar can be resized automatically or not with its contents.
LargeChange It is used to obtain or set a value that will be added or subtracted from the property of the scroll bar control when the scroll bar is moved a large distance.
Value It is used to obtain or set a value in a scroll bar control that indicates a scroll box’s current position.
DefaultImeMode It is used to get the default input method Editor (IME) that are supported by ScrollBar controls in the Windows Form.

Methods of the ScrollBar Control

Method Description
UpdateScrollInfo It is used to update the ScrollBar control using the Minimum, maximum, and the value of LargeChange properties.
OnScroll(ScrollEventArgs) It is used to raise the Scroll event in the ScrollBar Control.
OnEnabledChanged It is used to raise the EnabledChanged event in the ScrollBar control.
Select It is used to activate or start the ScrollBar control.
OnValueChanged(EventArgs) It is used to raise the ValueChanged event in the ScrollBar control.

Events of the ScrollBar Control

Event Description
AutoSizeChanged The AutoSizeChanged event is found in the ScrollBar control when the value of the AutoSize property changes.
Scroll The Scroll event is found when the Scroll control is moved.
TextChangedEvent It occurs in the ScrollBar control when the value of the text property changes.
ValueChanged A ValueChanged event occurs when the property of the value is changed programmatically or by a scroll event in the Scrollbar Control.

Furthermore, we can also refer to VB.NET Microsoft documentation to get a complete list of ScrollBar control properties, methods, and events in the VB.NET.

Let’s create a simple program to understand the use of ScrollBar Control in the VB.NET Windows Forms.

ScrollBar.vb

Output:

VB.NET ScrollBars Control


You may also like