Download presentation
Presentation is loading. Please wait.
Published byEugenia Arnold Modified over 8 years ago
1
Visual Basic.NET BASICS Lesson 14 Menus and Printing
2
2 Objectives Create menus using the MainMenu object. Write code for a menu command. Use check marks in menus. Create submenus.
3
3 Objectives (continued) Insert separator lines in menus. Print from Visual Basic.NET.
4
4 Creating Menus Using the Menu Editor A menu is a list of related items that can be selected to cause an event. Visual Basic.NET allows you to create standard menus that pull down from the menu bar. To make creating menus easier, Visual Basic.NET includes a MainMenu object. The menu structure on the form is called the Menu Designer.
5
5 Writing Code for a Menu Command Writing code for a menu command is much like writing code for a command button. When you code a menu command, you write an event procedure to handle the Click event.
6
6 Using Check Marks in Menus To help the user determine when the item is active, a check mark can be made to appear in the menu. You can add a check mark to a menu in the Menu Designer. You can also make a check mark appear and disappear by using Visual Basic.NET code.
7
7 Creating a Submenu Submenus are often used to further organize the options in a menu. Using the right arrow while in the menu designer creates submenus.
8
8 Inserting Separator Lines in Menus Using separator lines between some menu items can often improve readability, especially on large menus. The separator lines group the items on the menu, making the menu more user friendly. To create a separator line, right-click the Menu Designer at the location you want the separator and select Insert Separator.
9
9 Printing from Visual Basic.NET Visual Basic.NET provides a variety of ways to print. The PrintDocument object is a collection of prewritten code that allows you to communicate with the printer. The printing will be handled by a subroutine that you will create to handle the Print event.
10
10 Summary Most Windows programs provide menus as part of the user interface. Visual Basic. NET allows you to create menus without writing code by using the Menu Designer. A menu item’s Text property specifies the text that will appear on the menu. Menu items also have a Name property that is used to identify the menu item in code.
11
11 Summary (continued) When the user selects a command from a menu, a Click event is triggered. Writing code for a menu item is like writing any other Click event procedure. Check marks may be added to the items in a menu to indicate that an option is on or off.
12
12 Summary (continued) To better organize menus, you can insert separator lines from the Menu Designer. Separator lines cannot be selected by the user, but they can help group menu items. You can print text to the printer using the PrintDocument object. The PrintDocument object allows you to draw text strings to the default printer.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.