Events and Delegates
Events and delegates are closely associated in Visual Basic .NET. An event is a message sent by an object announcing that something important has happened. Events are implemented using delegates, a form of object-oriented function pointer that allows a function to be invoked indirectly by way of a reference to the function.
In This Section
- Events and Event Handlers
- Provides an overview of events, event handlers, and associated terminology.
- Adding Events to a Class
- Describes the process of defining events.
- Writing Event Handlers
- Demonstrates how to write event handlers using the Handles clause or the AddHandler statement.
- WithEvents and the Handles Clause
- Demonstrates how to use the WithEvents keyword and the Handles clause to associate an event with an event handler.
- AddHandler and RemoveHandler
- Demonstrates how to use the AddHandler and RemoveHandler statements to dynamically associate an event with an event handler.
- Event Handler Example
- Defines a class that raises an event when you call the CauseEvent method.
- Delegates and the AddressOf Operator
- Provides an introduction to delegates and how they are used.
- Delegate Example
- Creates a sort procedure in a class that uses the standard alphabetic sort on most list boxes, but is able to switch at run time to a custom sort procedure. To do this, you pass the custom sort procedure to the sort class at run time, using delegates.
- Walkthrough: Declaring and Raising Events
- Steps you through the process of declaring and raising events for a class.
- Walkthrough: Handling Events
- Demonstrates how to write an event handler procedure.
- Handling and Raising Events
- Provides an overview of the event model in the .NET Framework.
Describes how to work with events associated with Windows Forms objects.