8.3. Windows forms and events
Windows forms applications are event-based. This means that each user or system action, such as pressing a button, selecting an item in a list box, or repainting a window or its area causes an event. In order to intercept these events, we create event handlers – subroutines that contain pieces of code that are executed when the particular events occur. All Windows forms events are based on a feature of the common language runtime called “delegates”. We can think of delegates as type-safe, secure function pointers. For more information on events and delegates, see Chapter 3.
Each event defined in the Control class has an event delegate with a signature that looks like EventName EventHandler. For example, the Click ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access