This is a migrated thread and some comments may be shown as answers.

Trackbar Range

1 Answer 104 Views
TrackBar
This is a migrated thread and some comments may be shown as answers.
Eduard
Top achievements
Rank 1
Eduard asked on 19 Jul 2013, 10:52 AM
Hello,

I'm trying to use the RadTrackBar with Range mode, but I cannot access the values of the two ranges. I see in the documentation that I must use Ranges_CollectionChanged, but I don't understand how to access this function.

Do you have any example how to use two ranges.

Thank you,
Eduard

1 Answer, 1 is accepted

Sort by
0
George
Telerik team
answered on 24 Jul 2013, 07:49 AM
Hi Eduard,

Thank you for writing.

Indeed to find the start and end values of the trackbar you need to subscribe to the CollectionChanged event of the Ranges collection in the RadTrackBar. Then on each change you can check the Action type and find the TrackBarRange element we need which has Start and End properties. Please take a look at the code snippet below. 
public Form1()
{
    InitializeComponent();
 
    this.radTrackBar1.TrackBarMode = TrackBarRangeMode.Range;
    this.radTrackBar1.Ranges.CollectionChanged += Ranges_CollectionChanged;
}
 
private void Ranges_CollectionChanged(object sender, Telerik.WinControls.Data.NotifyCollectionChangedEventArgs e)
{
    if (e.Action == Telerik.WinControls.Data.NotifyCollectionChangedAction.ItemChanged)
    {
        foreach (object item in e.NewItems)
        {
            TrackBarRange range = item as TrackBarRange;
            if (range != null)
            {
                Console.WriteLine("Range {0} value {1}", range.Start, range.End);
            }
        }
    }
}

Hope this helps, if you have any other questions or comments, please let me know.
 
Regards,
George
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
TrackBar
Asked by
Eduard
Top achievements
Rank 1
Answers by
George
Telerik team
Share this question
or