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
Common use cases for ScrollBar Control
ScrollBar Control is a standard Windows Forms element that appears in most VB.NET desktop apps. Typical uses:
- User input capture. Bind to viewmodel properties for two-way data flow.
- Display of collections. Populate with in-memory lists, database result sets, or file system contents.
- Event-driven behaviors. Wire up Click, SelectedIndexChanged, or KeyDown handlers for interactivity.
- Data validation. Use Validating and Validated events to enforce input rules before persistence.
- Custom styling. Override OnPaint or use owner-draw modes for branded looks.
Wiring ScrollBar Control into your form
The standard pattern for adding ScrollBar Control at runtime looks like this:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
' Configure the control's initial state
Me.Text = "ScrollBar Control Example"
' Attach event handlers programmatically
AddHandler MyControl.Click, AddressOf MyControl_Click
End Sub
Private Sub MyControl_Click(sender As Object, e As EventArgs)
' React to user interaction here
MessageBox.Show("Control was clicked")
End Sub
End Class
Best practices for ScrollBar Control
- Name controls consistently. Use a Hungarian-style prefix (btn, txt, lbl, lst) so the codebehind reads cleanly.
- Group related controls in a Panel or GroupBox. Improves layout maintainability and keyboard tab order.
- Set TabIndex explicitly. Do not rely on design-time order; keyboard navigation matters for accessibility.
- Use data binding when possible. Avoid manual .Text = someValue assignments scattered across the codebehind.
- Handle Dispose(). Custom controls that hold GDI resources must implement IDisposable properly.
Troubleshooting ScrollBar Control
- Event handler does not fire. Confirm the Handles clause matches the exact control name, or that AddHandler was called.
- Design-time appearance differs from runtime. This usually means custom OnPaint code is not respecting DesignMode. Check with Me.DesignMode.
- Control flashes or flickers on redraw. Enable double-buffering by setting DoubleBuffered = True on the parent form.
- Cross-thread exceptions. UI updates from background threads must use Control.Invoke() or the BackgroundWorker.ReportProgress pattern.




