Need ArrowUp/Down Click Event

4 posts, 0 answers
  1. Javier
    Javier avatar
    2 posts
    Member since:
    Sep 2013

    Posted 05 Sep 2013 Link to this post

    Hi everyone,

    I'm using two Telerik NumericUpDown controllers (lets say A and B)

    If A is edited B is set to 0

    If B is edited A is set to B.Value * Variable

    If I use only the ValueChanged event I'm not able to implement this.

    Is it possible to capture arrowUp or arrowDown clik events?


    Thanks everyone, I hope I made myself clear, sorry if not it's my first post here.
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 10 Sep 2013 Link to this post

    Hello,

    In the current version of RadNumericUpDown there aren't explicit events that are being called when the value is changed via the up and down buttons of the control.

    The described scenario is out of the scope of the control and we do not have a sample project that we can share with you that shows how it could be achieved.

    Regards,
    Vladi
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
    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 WPF is Visual Studio 2017 Ready
  4. Javier
    Javier avatar
    2 posts
    Member since:
    Sep 2013

    Posted 10 Sep 2013 Link to this post

    Thanks for your response!

    I tried via LostFocus and similars but it wasn't the correct approach either.

    Thanks anyway.
  5. Pooja
    Pooja avatar
    10 posts
    Member since:
    Oct 2014

    Posted 23 Oct 2014 Link to this post

    Hi,

    I wanted to capture the up/down events as well and as a work around ended up implementing my own version of the control. Hope this helps.
    public class CustomRadNumericUpDown : RadNumericUpDown
        {
            /// <summary>
            /// Overrides OnApplyTemplate and attaches click events to the controls.
            /// </summary>
            public override void OnApplyTemplate()
            {
                // Subscribe to button click and up/down key events before base.OnApplyTemplate()
                // so that our handler gets called prior to the original Telerik’s one.
                var textBox = GetTemplateChild("textbox") as TextBox;
                if (textBox != null)
                {
                    textBox.PreviewKeyDown += TextBox_PreviewKeyDown;
                }
     
                var increaseButton = GetTemplateChild("increase") as RepeatButton;
                if (increaseButton != null)
                {
                    increaseButton.Click += OnClick;
                }
     
                var decreaseButton = GetTemplateChild("decrease") as RepeatButton;
                if (decreaseButton != null)
                {
                    decreaseButton.Click += OnClick;
                }
     
                base.OnApplyTemplate();
            }
     
            void TextBox_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
            {
                if (e.Key == Key.Up || e.Key == Key.Down || e.Key == Key.PageUp || e.Key == Key.PageDown)
                {
                    OnClick(sender, e);
                }
            }
     
            private void OnClick(object sender, RoutedEventArgs e)
            {
              if (!Value.HasValue || Value == 0.0)
               {
                        // Handle your event
                        // Note that parameter to this.ChangeValue() is a delta value,
                        // rather than the value that will be set (in our case, since value is null it will also be a value that will be set).
                        ChangeValue(78.88);
                      // Set e.handled to true if you do not want the default handler to run (which increments/decrements the Value by delta)
                    e.Handled = true;
                 }
                 
            }
        }
Back to Top