New to Telerik UI for WinForms? Download free 30-day trial

Modes

RadTrackBar supports three different modes - SingleThumb, StartFromTheBeginning and Range. Each of these modes defines its own functionality and behavior. You can change the mode of the control via its TrackBarMode property.

SingleThumb

In this mode RadTrackBar works like a standard TrackBar. It contains one thumb and its value can be accessed through the Value property of RadTrackBar. To receive notification when value is changed you can use the ValueChanged event.

Figure 1: SingleThumb

WinForms RadTrackBar SingleThumb

StartFromTheBeginning

In this mode RadTrackBar looks like RadTrackBar in SingleThumb mode, but it can contain more than one thumb. To show more than one thumb you should add the desired ranges (TrackBarRange) in the Ranges collection of control. For example:

this.radTrackBar1.TrackBarMode = Telerik.WinControls.UI.TrackBarRangeMode.StartFromTheBeginning;
this.radTrackBar1.Ranges.Add(new TrackBarRange(0, 5, "MyRange1"));
this.radTrackBar1.Ranges.Add(new TrackBarRange(0, 15, "MyRange2"));

Me.RadTrackBar1.TrackBarMode = Telerik.WinControls.UI.TrackBarRangeMode.StartFromTheBeginning
Me.RadTrackBar1.Ranges.Add(New TrackBarRange(0, 5, "MyRange1"))
Me.RadTrackBar1.Ranges.Add(New TrackBarRange(0, 15, "MyRange2"))

WinForms RadTrackBar StartFromTheBeginning

In order to access the values of the thumbs in this mode you should go through the Ranges collection and check the values of each TrackBarRange. Please, note that even though TrackBarRange has both Start and End properties, in this mode RadTrackBar uses only the End property, so you should access it in order to take the value of some range.

float fitstRangeValue = this.radTrackBar1.Ranges[0].End;
float secondRangeValue = this.radTrackBar1.Ranges[1].End;

Dim fitstRangeValue As Single = Me.RadTrackBar1.Ranges(0).[End]
Dim secondRangeValue As Single = Me.RadTrackBar1.Ranges(1).[End]

To receive notification when the Value is changed in this mode, you should use the RangeValueChanged event of the RadTrackBar:

private void RadTrackBar1_RangeValueChanged(object sender, RangeChangedEventArgs e)
{
    Console.WriteLine("Radge {0} Start {1}, End {2}", e.ChangedRange.Text, e.ChangedRange.Start, e.ChangedRange.End);
}

Private Sub RadTrackBar1_RangeValueChanged(ByVal sender As Object, ByVal e As RangeChangedEventArgs)
    Console.WriteLine("Radge {0} Start {1}, End {2}", e.ChangedRange.Text, e.ChangedRange.Start, e.ChangedRange.End)
End Sub

Range

This mode allows you to define one or more Ranges with Start and End values. In this mode there the Ranges cannot to overlap each other. To display a second range, you should add the desired Range (TrackBarRange) in the Ranges collection of the control. For example:

this.radTrackBar1.TrackBarMode = Telerik.WinControls.UI.TrackBarRangeMode.Range;
this.radTrackBar1.Ranges[0].Start = 2;
this.radTrackBar1.Ranges[0].End = 5;
this.radTrackBar1.Ranges.Add(new TrackBarRange(10, 15));

Me.RadTrackBar1.TrackBarMode = Telerik.WinControls.UI.TrackBarRangeMode.Range
Me.RadTrackBar1.Ranges(0).Start = 2
Me.RadTrackBar1.Ranges(0).[End] = 5
Me.RadTrackBar1.Ranges.Add(New TrackBarRange(10, 15))

WinForms RadTrackBar Range

To receive notification when the Value is changed in this mode, you should use the RangeValueChanged event of the RadTrackBar:

private void RadTrackBar1_RangeValueChanged(object sender, RangeChangedEventArgs e)
{
    Console.WriteLine("Radge {0} Start {1}, End {2}", e.ChangedRange.Text, e.ChangedRange.Start, e.ChangedRange.End);
}

Private Sub RadTrackBar1_RangeValueChanged(ByVal sender As Object, ByVal e As RangeChangedEventArgs)
    Console.WriteLine("Radge {0} Start {1}, End {2}", e.ChangedRange.Text, e.ChangedRange.Start, e.ChangedRange.End)
End Sub

The Ranges collection of RadTrackBar contains one default range that is used to display a default range for all modes. This collection should always contain at least one range, so if you execute the Clear method of the collection all ranges except the first one will be removed.

When the mode is changed from StartFromTheBeginning to something else, the Ranges collection will be reset to prevent overlappings that are not allowed in the other modes.

See Also

In this article