Chapter 4: Working with Menus, Toolbars, and Dialog Boxes


Chapter 4

Working with Menus, Toolbars, and Dialog Boxes

After completing this chapter, you will be able to:

  • Add menus to your programs by using the MenuStrip control.

  • Process menu and toolbar selections by using event procedures and the Code Editor.

  • Add toolbars and buttons by using the ToolStrip control.

  • Use the OpenFileDialog and ColorDialog controls to create standard dialog boxes.

  • Add access keys and shortcut keys to menus.

In Chapter 3, “Working with Toolbox Controls,” you used several Microsoft Visual Studio 2005 controls to gather input from the user while he or she used a program. In this chapter, you'll learn how to present choices to the user by creating professional-looking menus, toolbars, and dialog boxes.

A menu is located on the menu bar and contains a list of related commands; a toolbar contains buttons and other tools that perform useful work in a program. Most menu and toolbar commands are executed immediately after they're clicked; for example, when the user clicks the Copy command on the Edit menu, information is copied to the Clipboard immediately. If a menu command is followed by an ellipsis (…), however, clicking the command displays a dialog box requesting more information before the command is carried out, and many toolbar buttons also display dialog boxes.

In this chapter, you'll learn how to use the MenuStrip and Toolstrip controls to add a professional look to your application's user interface. You'll also learn how to process menu, toolbar, and dialog box commands.

Upgrade Notes: Migrating Visual Basic 6 Code to Visual Basic 2005

If you're experienced with Microsoft Visual Basic 6, you'll notice some new features in Microsoft Visual Basic 2005, including the following:

  • Menus are no longer created by using the Visual Basic 6 Menu Editor tool. Instead, you create a menu strip object on your form by using the MenuStrip control and then customize the object by using property settings and the Menu Designer. However, menu choices are still processed with program code.

  • The Visual Basic 6 Toolbar and Coolbar controls have been replaced by the ToolStrip control.

  • Standard dialog boxes are no longer created by using the CommonDialog control. Instead, you use one of eight Windows Forms controls that add standard dialog boxes to your project. These controls are OpenFileDialog, SaveFileDialog, FolderBrowserDialog, FontDialog, ColorDialog, PrintDialog, PrintPreviewDialog, and Page-SetupDialog.

  • Forms now feature the ShowDialog method and the DialogResult property, making it easier to create custom forms that look and act like standard dialog boxes.



Microsoft Visual Basic 2005 Step by Step
Microsoft Visual Basic 2005 Step by Step (Step by Step (Microsoft))
ISBN: B003E7EV06
EAN: N/A
Year: 2003
Pages: 168

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net