Hi, How do I get the event ‘TextBox_Validating’ to be called after text had been entered into a text box and the carriage return key had been pressed? At present after carriage return is pressed nothing happens. Focus remains with text box and after debugging it appears the event is never invoked. It seems focus needs to be moved away from text box for the event to be triggered. But I have no other controls after text box to focus on. Should I use another event such as Keypress before Validating to handle the carriage return? I would be very grateful for all suggestions.
How to use Validating event with a text box
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Muhammad Shahid Farooq107 reputationPosted Jan 28, 2009, 12:47 AM EST
Ray Dona, Use the following code
this will help you. //Key press event private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e){
//If the Enter key pressed when validate textbox value if(e.KeyChar == 13){
//User defined method in which validation is performedvalidateTextBox();
}
else{
e.Handled =
false;}
}
Satya3 reputationPosted Dec 15, 2010, 8:06 PM EST