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.

PropertyDescription
BackColorThe BackColor property is used to set the back color of the scroll bar.
MaximumIt is used to set or get the maximum value of the Scroll Bar control. By default, it is 100.
MinimumIt is used to get or set the minimum value of the Scroll bar control. By default, it is 0.
SmallChangeIt 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.
AutoSizeAs 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.
LargeChangeIt 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.
ValueIt is used to obtain or set a value in a scroll bar control that indicates a scroll box's current position.
DefaultImeModeIt 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

MethodDescription
UpdateScrollInfoIt 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.
OnEnabledChangedIt is used to raise the EnabledChanged event in the ScrollBar control.
SelectIt 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

EventDescription
AutoSizeChangedThe AutoSizeChanged event is found in the ScrollBar control when the value of the AutoSize property changes.
ScrollThe Scroll event is found when the Scroll control is moved.
TextChangedEventIt occurs in the ScrollBar control when the value of the text property changes.
ValueChangedA 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




Latest Courses