Represents the method that will handle the event that has no event data.
[Visual Basic] <Serializable> Public Delegate Sub EventHandler( _ ByVal sender As Object, _ ByVal e As EventArgs _ ) [C#] [Serializable] public delegate void EventHandler( object sender, EventArgs e ); [C++] [Serializable] public __gc __delegate void EventHandler( Object* sender, EventArgs* e );
[JScript] In JScript, you can use the delegates in the .NET Framework, but you cannot define your own.
The declaration of your event handler must have the same parameters as the EventHandler delegate declaration.
The event model in the .NET Framework is based on having an event delegate that connects an event with its handler. To raise an event, two elements are needed:
If the event does not generate data, use the base class EventArgs for the event data object, and the pre-defined EventHandler for the event delegate.
When you create an EventHandler delegate, you identify the method that will handle the event. To associate the event with your event handler, add an instance of the delegate to the event. The event handler is called whenever the event occurs, unless you remove the delegate. For more information about event handler delegates, see
[Visual Basic, C#] A declaration for a no-data event delegate is shown below, where EventHandler is the pre-defined event delegate, sender is the object that raises the event, and e is the event data object that contains no data. The second line defines the event member in your class for the no-data event.
[Visual Basic] Delegate Sub EventHandler(sender As Object, e As EventArgs) Public Event NoDataEventHandler As EventHandler [C#] public delegate void EventHandler(Object sender, EventArgs e); public event EventHandler NoDataEventHandler;
[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button
in the upper-left corner of the page.
Namespace: System
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework - Windows CE .NET
Assembly: Mscorlib (in Mscorlib.dll)
System Namespace | EventArgs | Delegate |