What is ScrollBar Control in VB.net?
A ScrollBar Control in VB.net is used to create and show vertical and horizontal scroll bars on the Windows form.
It is used when there is a lot of information in a form and we can’t see all of it.
Therefore, we used the VB.NET ScrollBar Control. In general, there are two kinds of ScrollBar: HScrollBar for horizontal scroll bars and VScrollBar for vertical scroll bars.
Let’s create a Scroll Bar in VB.net by dragging a Scroll Bar Control from the Toolbox and dropping it on the form.
ScollBar Control in VB.net Properties
The following given below are some commonly used Properties of the ScrollBar Control# ScollBar Control in VB.net Properties Description 1. AutoSize Gets or sets a value indicating whether the ScrollBar is automatically resized to fit its contents. 2. BackColor Gets or sets the background color for the control. 3. ForeColor Gets or sets the foreground color of the scroll bar control. 4. ImeMode Gets or sets the Input Method Editor (IME) mode supported by this control. 5. LargeChange Gets or sets a value to be added to or subtracted from the Value property when the scroll box is moved a large distance. 6. Maximum Gets or sets the upper limit of values of the scrollable range. 7. Minimum Gets or sets the lower limit of values of the scrollable range. 8. SmallChange Gets or sets the value to be added to or subtracted from the Value property when the scroll box is moved a small distance. 9. Value Gets or sets a numeric value that represents the current position of the scroll box on the scroll bar control.
ScrollBar Control in VB.net Methods
The following given below are some commonly used Methods of the ScrollBar Control.# ScrollBar Control in VB.net Methods Description 1. UpdateScrollInfo It is used to update the ScrollBar control using the Minimum, maximum, and the value of LargeChange properties. 2. OnScroll(ScrollEventArgs) It is used to raise the Scroll event in the ScrollBar Control. 3. OnEnabledChanged It is used to raise the EnabledChanged event in the ScrollBar control. 4. Select It is used to activate or start the ScrollBar control. 5. OnValueChanged(EventArgs) It is used to raise the ValueChanged event in the ScrollBar control.
ScrollBar Control in VB.net Events
The following given below are some commonly used Events of the ScrollBar Control in VB.net.# ScrollBar Control in VB.net Events Description 1. AutoSizeChanged The AutoSizeChanged event is found in the ScrollBar control when the value of the AutoSize property changes. 2. Scroll The Scroll event is found when the Scroll control is moved. 3. TextChangedEvent It occurs in the ScrollBar control when the value of the text property changes. 4. ValueChanged A ValueChanged event occurs when the property of the value is changed programmatically or by a scroll event in the Scrollbar Control.
Let’s create a simple program to understand the use of ScrollBar Control in the VB.NET Windows Forms.
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Text = "itsourcecode.com" 'Set the title for a Windows Form
Label1.Text = "Use of ScrollBar Control in Windows Form"
Label1.ForeColor = Color.DarkBlue
Me.AutoScroll = True
Me.VScrollBar1.Minimum = 0
Me.VScrollBar1.Maximum = 100
Me.VScrollBar1.Value = 0
Me.VScrollBar1.BackColor = Color.Blue
Me.HScrollBar1.Minimum = 0
Me.HScrollBar1.Maximum = 100
Me.HScrollBar1.Value = 35
End Sub
End ClassProgram Output:
Summary
A VB.net ScrollBar Control is used to add Vertical and Horizontal scrolling features to a Windows Forms control that does not have a built-in scrolling feature.
In this article, we discussed How To Create a ScrollBar Control VB.net using Microsoft Visual Studio in Windows Forms at design-time as well as run-time.
After that, we saw how to use various Properties, Methods, and Events.
PREVIOUS





