Trackbar Range

2 posts, 0 answers
  1. Eduard
    Eduard avatar
    7 posts
    Member since:
    Jul 2012

    Posted 19 Jul 2013 Link to this post

    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
  2. George
    Admin
    George avatar
    500 posts

    Posted 24 Jul 2013 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top