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

Need ArrowUp/Down Click Event

3 Answers 246 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Javier
Top achievements
Rank 1
Javier asked on 05 Sep 2013, 03:11 PM
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.

3 Answers, 1 is accepted

Sort by
0
Vladi
Telerik team
answered on 10 Sep 2013, 12:27 PM
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 >>
0
Javier
Top achievements
Rank 1
answered on 10 Sep 2013, 01:07 PM
Thanks for your response!

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

Thanks anyway.
1
Pooja
Top achievements
Rank 1
answered on 23 Oct 2014, 07:12 PM
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;
             }
             
        }
    }
Tags
NumericUpDown
Asked by
Javier
Top achievements
Rank 1
Answers by
Vladi
Telerik team
Javier
Top achievements
Rank 1
Pooja
Top achievements
Rank 1
Share this question
or