asp.net.ph

EventHandler Delegate

System Namespace


Represents the method that will handle the event that has no event data.

[ VB ]
Public Delegate Sub EventHandler ( _
   ByVal sender As Object, _
   ByVal e As EventArgs _
)

[ C# ]
public delegate void EventHandler (
   object sender,
   EventArgs e
);

[ C++ ]
public __gc __delegate void EventHandler (
   Object* sender,
   EventArgs* e
);

In [ JScript ], you can use the delegates in the .NET Framework, but you cannot define your own.

Parameters [ VB, C#, C++ ]

The declaration of your event handler must have the same parameters as the EventHandler delegate declaration.

sender
The source of the event.
e
An EventArgs that contains the event data.

Remarks

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:

  • A class that holds the event data. This class must derive from the base class EventArgs.
  • A delegate that points to a method that provides the response to the event.

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 Events and Delegates.

See Also

EventArgs   Delegate Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph