INITIATING ACTION

Every kind of control responds to events, so every control can initiate an action. In practice, however, users expect only certain kinds of controls to perform actions. For example, they generally don’t expect the application to launch into a time-consuming calculation when the mouse moves over a label.

The following table summarizes controls that normally initiate action.

CONTROL PURPOSE
Button1 Raises a Click event that the program can catch to perform an action. (See example program UseButtonRepeatButton, available for download on the book’s website.)
ContextMenu Displays a context menu for other controls. Normally the ContextMenu contains MenuItem controls. (See example program UseMenuContextMenu, available for download on the book’s website.)
Menu Displays a menu for the form. Normally, the Menu contains MenuItem controls representing the top-level menus. Those items contain other MenuItem controls representing commands. (See example program UseMenuContextMenu, available for download on the book’s website.)
MenuItem Contains an item in a ContextMenu or Menu.
PrintDialog Displays a standard Windows print dialog. You shouldn’t place a PrintDialog on a window. Instead use code to build and display the PrintDialog. (See example program UsePrintDialog, available for download on the book’s website.)
RepeatButton1 Acts as a Button that raises its Click event repeatedly when it is pressed and held down. (See example program UseButtonRepeatButton, ...

Get Visual Basic 2012 Programmer's Reference 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.