Sorry, I am using C++ syntax, but it should be the same for C#. How can I call one event from within another? For example, say I have the two events, one for a button and one for a textbox.
private: System::Void Button_Click(System::Object^ sender, System::EventArgs^ e)
private: System::Void TextBox_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e)
In the button’s click event after processing something I wish to focus on text box and validate user input in textbox. I have tried the following:
private: System::Void Button_Click(System::Object^ sender, System::EventArgs^ e)
{ // Do something
if(TextBox->CanFocus == true)
{ TextBox->Focus();
}
TextBox_KeyPress();
}
It doesn’t work because I do not know what arguments to pass. Also after validating user input in KeyPress event I wish to return to Button_Click event. Can I do that by simply saying ‘return’ in KeyPress event? Thank you for all help.
private: System::Void Button_Click(System::Object^ sender, System::EventArgs^ e)
private: System::Void TextBox_KeyPress(System::Object^ sender, System::Windows::Forms::KeyPressEventArgs^ e)
In the button’s click event after processing something I wish to focus on text box and validate user input in textbox. I have tried the following:
private: System::Void Button_Click(System::Object^ sender, System::EventArgs^ e)
{ // Do something
if(TextBox->CanFocus == true)
{ TextBox->Focus();
}
TextBox_KeyPress();
}
It doesn’t work because I do not know what arguments to pass. Also after validating user input in KeyPress event I wish to return to Button_Click event. Can I do that by simply saying ‘return’ in KeyPress event? Thank you for all help.