ScrollBar Control in VB.net – Properties, Methods and Events

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.

ScrollBar Control in VB.net Tutorial

ScollBar Control in VB.net Properties

The following given below are some commonly used Properties of the ScrollBar Control

#ScollBar Control in VB.net PropertiesDescription
1.AutoSizeGets or sets a value indicating whether the ScrollBar is automatically resized to fit its contents.
2.BackColorGets or sets the background color for the control.
3.ForeColorGets or sets the foreground color of the scroll bar control.
4.ImeModeGets or sets the Input Method Editor (IME) mode supported by this control.
5.LargeChangeGets or sets a value to be added to or subtracted from the Value property when the scroll box is moved a large distance.
6.MaximumGets or sets the upper limit of values of the scrollable range.
7.MinimumGets or sets the lower limit of values of the scrollable range.
8.SmallChangeGets or sets the value to be added to or subtracted from the Value property when the scroll box is moved a small distance.
9.ValueGets 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 MethodsDescription
1.UpdateScrollInfoIt 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.OnEnabledChangedIt is used to raise the EnabledChanged event in the ScrollBar control.
4.SelectIt is used to activate or start the ScrollBar control.
5.OnValueChanged(EventArgs)It is used to raise the ValueChanged event in the ScrollBar control.
Methods and Descriptions of 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 EventsDescription
1.AutoSizeChangedThe AutoSizeChanged event is found in the ScrollBar control when the value of the AutoSize property changes.
2.ScrollThe Scroll event is found when the Scroll control is moved.
3.TextChangedEventIt occurs in the ScrollBar control when the value of the text property changes.
4.ValueChangedA ValueChanged event occurs when the property of the value is changed programmatically or by a scroll event in the Scrollbar Control.
Events and Descriptions of 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 Class

Program Output:

ScrollBar Control in VB.net Output
ScrollBar Control 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.


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.

Frequently Asked Questions

What is the ScrollBar Control in VB.NET used for?
The ScrollBar Control is a Windows Forms control that captures user input or displays data in a familiar UI element. It sits in the Toolbox in Visual Studio and can also be created at runtime through code.
How do I add the ScrollBar Control to my form?
Drag it from the Visual Studio Toolbox onto the form designer, or instantiate it in code with New and add it to Me.Controls. Both approaches produce identical runtime behavior.
What are the most-used ScrollBar Control properties?
Name, Text, Location, Size, and Enabled are set on almost every instance. Font, ForeColor, and BackColor are common for styling. Anchor and Dock control how the control resizes with the form.
How do I handle ScrollBar Control events?
Double-click the control in the form designer to auto-generate a default event handler. Or wire up manually with AddHandler MyControl.EventName, AddressOf HandlerMethod inside Form_Load.
Can I use the ScrollBar Control in WPF or MAUI?
No. Windows Forms controls are specific to WinForms. WPF has its own control hierarchy under System.Windows.Controls, and MAUI uses cross-platform equivalents. Use the framework-appropriate control instead.
Angel Jude Suarez


Full-Stack Developer at PIES IT Solution

Focuses on Python development, machine learning, and AI integration. Has built production AI systems including OpenAI Whisper integration for medical transcription and GPT-4o-powered diagnosis assistance. Strong background in pandas, scikit-learn, and TensorFlow.

Expertise: Python · PHP · Java · VB.NET · ASP.NET · Machine Learning · AI Integration · OpenCV · Django · CodeIgniter
 · View all posts by Angel Jude Suarez →

Leave a Comment