Getting Started with Windows Forms TrackBar

10 Oct 20224 minutes to read

This section describes how to add Windows Forms TrackBar control in a Windows Forms application and overview of its basic functionalities.

Assembly deployment

Refer to the control dependencies section to get the list of assemblies or details of NuGet package that needs to be added as a reference to use the control in any application.

Click NuGet Packages to learn how to install nuget packages in Windows Forms application.

Adding TrackBarEx control via designer

  1. Create a new Windows Forms project in Visual Studio.

  2. The TrackBarEx control can be added to an application by dragging it from the toolbox to a design view. The following dependent assemblies will be added automatically:

    • Syncfusion.Grid.Base
    • Syncfusion.Grid.Windows
    • Syncfusion.Shared.Base
    • Syncfusion.Shared.Windows
    • Syncfusion.Tools.Base
    • Syncfusion.Tools.Windows

TrackBarEx control added via designer

Add control manually in code

To add the control manually in C#, follow the given steps:

  1. Create C# or VB application via Visual Studio.

  2. Add the following assembly references to the project:

    • Syncfusion.Grid.Base
    • Syncfusion.Grid.Windows
    • Syncfusion.Shared.Base
    • Syncfusion.Shared.Windows
    • Syncfusion.Tools.Base
    • Syncfusion.Tools.Windows
  3. Include the required namespace.

using Syncfusion.Windows.Forms.Tools;
Imports Syncfusion.Windows.Forms.Tools
  1. Create an instance of TrackBarEx control, and add it to the window.

//Instance of TrackBarEx
   TrackBarEx trackBarEx1 = new TrackBarEx();
   trackBarEx1.Value = 5;
   this.Controls.Add(trackBarEx1);
'Instance of TrackBarEx
   Dim trackBarEx1 As TrackBarEx = New TrackBarEx
   trackBarEx1.Value = 5
   Me.Controls.Add(tabSplitterContainer1)

TrackBarEx control added via code

Change value

You can define the minimum and maximum values by setting the Minimum and Maximum properties of TrackBarEx.

this.trackBarEx1.Minimum = 10;
this.trackBarEx1.Maximum = 30;
Me.trackBarEx1.Minimum = 10
Me.trackBarEx1.Maximum = 30

Windows Forms TrackBarEx showing minimum and maximum value

Horizontal or vertical track bar

The TrackBarEx control can be oriented horizontally or vertically using the Orientation property.

// To set the control to be vertically oriented.
this.trackBarEx1.Orientation = Orientation.Vertical;

// To set the control to be horizontally oriented.
this.trackBarEx1.Orientation = Orientation.Horizontal;
'To set the control to be vertically oriented.
Me.trackBarEx1.Orientation = Orientation.Vertical

'To set the control to be horizontally oriented.
Me.trackBarEx1.Orientation = Orientation.Horizontal

TrackBarEx control orientation