Chapter V.4. Wiring Up Events in the User Interface
In This Chapter
Say that you create a Windows Form that requires a user to enter her username and password. Maybe you create a Web page with a drop-down list of state names that you want populated when the user browses to the page. Or, you add a Print command to a menu that you want to execute the command to print a report. What do all these scenarios have in common?
All these scenarios require some action to occur before your code can execute. A user must submit his credentials; a Web page loads; a user clicks a menu command. All these actions are events.
You can probably think of several events off the top of your head: click, double-click, hover, and exit. You probably associate events with direct actions that a user takes to interact with your program. In reality, events go way beyond mere button clicking and mouse hovering. Events allow your entire application, as well as each form and control within the application, to have its own life cycle. From the moment your application fires up until the moment it shuts down, events are firing along the way.
As you already likely know, code fires in response to events, such as button clicks. Taking advantage of the events in an application and control life cycles allows you to run code at a precise moment in an application's or a control's life cycle. Instead of waiting for a user to click a button, you can run code as soon as your application starts — or even when a user's cursor leaves ...
Get Visual Studio® 2008 ALL-IN-ONE DESK REFERENCE FOR DUMMIES® now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.