Standard Event Declaration
suggest changeEvent declaration:
public event EventHandler<EventArgsT> EventName;
Event handler declaration:
public void HandlerName(object sender, EventArgsT args) { /* Handler logic */ }
Subscribing to the event:
Dynamically:
EventName += HandlerName;
Through the Designer:
- Click the Events button on the control’s properties window (Lightening bolt)
- Double-click the Event name:
- Visual Studio will generate the event code:
private void Form1_Load(object sender, EventArgs e)
{
}
Invoking the method:
EventName(SenderObject, EventArguments);
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents