You can use the Forms Designer to create event handlers. An event handler is a routine in your code that determines which actions to perform when an event occurs, such as the user's clicking a button.
For example, the event handler for the mouseDown event provides a mouseEvent object that allows you to determine which mouse button was pressed, where the mouse was positioned on the form, and which keys on the keyboard were pressed during the click.
You can add an event handler using the events view in the Properties window. A handler for the default event can also be added by double-clicking. Moreover, you can assign an existing handler to the events of other controls if the signatures of the events are the same.
To add an event handler using the events view of the Properties window
A code template is generated in your code similar to the following:
private void MyButton_click(Object sender, Event e) {
}
In this example, sender is the source of the event and e is an Event object that provides information about the event.
To add a handler for the default event
-or-
To use to the same handler for events shared by multiple controls