Tab on Enter Key

3 posts, 1 answers
  1. Vic
    Vic avatar
    36 posts
    Member since:
    Aug 2012

    Posted 28 Aug 2012 Link to this post

    Hello,
    I'm trying to get the NumericUpDown to tab to the next control when the user presses Enter.  Handling the KeyUp or KeyDown event with the following code does not work: 
    (sender as RadNumericUpDown).MoveFocus(new TraversalRequest(System.Windows.Input.FocusNavigationDirection.Next));
    e.Handled = true;

    Any suggestions?

     

     



  2. Answer
    Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 03 Sep 2012 Link to this post

    Hi,

    We reproduced this behavior at our side. We will do our best to fix it for one of our future releases. There is an easy workaround for it. If you get the TextBox part of the RadNumericUpDown and call MoveFocus to it this will work as expected.
    var numericUpDown = (RadNumericUpDown)sender;
    var textBox = numericUpDown.ChildrenOfType<TextBox>().FirstOrDefault();
    textBox.MoveFocus(new TraversalRequest(System.Windows.Input.FocusNavigationDirection.Next));
    e.Handled = true;

    We don't usually recommend using ChildrenOfType extension method, but at this case you can call it only once into the RadNumericUpDown's Loaded event and store the found TextBox into a variable. This way the workaround will not affect the performance of your application.

    Regards,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Vic
    Vic avatar
    36 posts
    Member since:
    Aug 2012

    Posted 03 Sep 2012 Link to this post

    Thank you, Ivo.  The work around works fine.
Back to Top