"Enter" pressing event

5 posts, 0 answers
  1. Dandan
    Dandan avatar
    17 posts
    Member since:
    Mar 2009

    Posted 11 May 2009 Link to this post

    Hi,

    How can I catch "Enter pressing" event?

    Thank,
    Dana.
  2. Valentin.Stoychev
    Admin
    Valentin.Stoychev avatar
    2198 posts

    Posted 11 May 2009 Link to this post

    Hi Dandan,

    You need to handle the KeyDown event:

    XAML:

    <

     

    telerikInput:RadMaskedTextBox KeyDown="RadMaskedTextBox_KeyDown"></telerikInput:RadMaskedTextBox>

     


    Code Behind:
     
            private void RadMaskedTextBox_KeyDown(object sender, KeyEventArgs e)  
            {  
                if (e.Key == Key.Enter)  
                {   
                    // place your code here  
                }  
            } 


    Kind regards,
    Valentin.Stoychev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. DevCraft banner
  4. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 11 May 2009 Link to this post

    Hi Dandan,

    Please attach to the "KeyUp" event (note that KeyDown won't work for RadNumericUpDown) of the RadNumericUpDown  and then use this code:
    private void timepicker_KeyUp(object sender, KeyEventArgs e) 
            {  
                if (e.Key.ToString()== "Enter" ) 
                { 
                    MessageBox.Show("Enter Pressed"); 
                } 
            } 

     Hope that helps. If you need more help let me know.

    Best wishes,
    Boyan
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. Neal Sanche
    Neal Sanche avatar
    6 posts
    Member since:
    Oct 2009

    Posted 02 Feb 2010 Link to this post

    So, if I wanted to have the numeric-up-down 'commit' its value when the Enter key is pressed, what code would you write inside the Enter KeyUp handler to do so? There doesn't seem to be any form of 'End Edit' method on this control to do so.

    Thanks for any advice you can give.

    -Neal
  6. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 08 Feb 2010 Link to this post

    Hi Neal Sanche,

    You can try this:
    private void numeric1_KeyDown(object sender, KeyEventArgs e)
    {
        if (e.Key == Key.Enter)
        {
            if (string.IsNullOrEmpty((sender as RadNumericUpDown).ContentText))
            {
                (sender as RadNumericUpDown).Value = null;
            }
            else
            {
                (sender as RadNumericUpDown).Value = Convert.ToDouble((sender as RadNumericUpDown).ContentText);
            }
        }
    }

    If you need more help please let me know.


    Kind regards,
    Boyan
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top
DevCraft banner