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

"Enter" pressing event

4 Answers 132 Views
NumericUpDown
This is a migrated thread and some comments may be shown as answers.
Dandan
Top achievements
Rank 1
Dandan asked on 11 May 2009, 10:15 AM
Hi,

How can I catch "Enter pressing" event?

Thank,
Dana.

4 Answers, 1 is accepted

Sort by
0
Valentin.Stoychev
Telerik team
answered on 11 May 2009, 11:19 AM
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.
0
Boyan
Telerik team
answered on 11 May 2009, 01:33 PM
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.
0
Neal Sanche
Top achievements
Rank 1
answered on 02 Feb 2010, 09:16 PM
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
0
Boyan
Telerik team
answered on 08 Feb 2010, 02:02 PM
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.
Tags
NumericUpDown
Asked by
Dandan
Top achievements
Rank 1
Answers by
Valentin.Stoychev
Telerik team
Boyan
Telerik team
Neal Sanche
Top achievements
Rank 1
Share this question
or