HScrollbar behave like NumericUpandDown?

2 posts, 0 answers
  1. Web
    Web avatar
    88 posts
    Member since:
    Nov 2006

    Posted 08 Dec 2006 Link to this post

    I am looking for a Control which behaves like the Numeric UPAndDown Control. Would be there any way to get the HScrollbar working like it or do you have any other suggestions?
    thank you
  2. Angel
    Admin
    Angel avatar
    121 posts

    Posted 11 Dec 2006 Link to this post

    Hi Kerstin,

    HScrollBar and VScrollBar cannot be used directly as the control you need. However, you can achieve similar behavior with a few lines of code:

    1. Hide the scroll thumb.

        this.radHScrollBar1 = new Telerik.WinControls.UI.RadHScrollBar();
        ...
        this.radHScrollBar1.ScrollBarElement.Children[4].Visibility = Telerik.WinControls.ElementVisibility.Collapsed;


    2. If the user clicks in the area between the two scroll buttons LargeScroll events will be raised (Page Up/Down for vertical scroll or Page Left/Right for horizontal scroll). You can handle the "Scroll" and the "ValueChanged" events to disable this behavior.

            private bool largeValueChanging = false;
            private int oldValue;

            private void radHScrollBar1_Scroll(object sender, ScrollEventArgs e)
            {
                if (e.Type == ScrollEventType.LargeDecrement || e.Type == ScrollEventType.LargeIncrement)
                {
                    this.largeValueChanging = true;
                    RadScrollBar scrollBar = (RadScrollBar)sender;
                    this.oldValue = e.OldValue;
                }
            }

            private void radHScrollBar1_ValueChanged(object sender, EventArgs e)
            {
                if (this.largeValueChanging)
                {
                    this.largeValueChanging = false;
                    RadScrollBar scrollBar = (RadScrollBar)sender;
                    scrollBar.Value = this.oldValue;
                }
            }

    Let us know if you experience any problems with this approach.


    Kind regards,
    Angel
    the telerik team
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top