I am implementing a WinForms form in a C# project.
My form is a child of a MDI form.
My form contains a user control.
My user control contains some buttons including a validation button and a cancel one.
I want to implement the following logic :
- When my form is active and the user presses the enter key then I want the validation button clicked event to be fired automatically.
- When my form is active and the user presses the escape key then I want the cancel button clicked event to be fired automatically.
If my validation and my cancel buttons were not included in a user control then I would probably set the AcceptButton and CancelButton properties of my form.
Here is the code I have written in the Load event handler of my user control according to a tip given by Arthur in a comment to my first post :