Presentation is loading. Please wait.

Presentation is loading. Please wait.

Compunet Corporation Programming with Visual Basic.NET Working with Menus and Dialog Boxes Week 14 Tariq Aziz and Kevin Jones.

Similar presentations


Presentation on theme: "Compunet Corporation Programming with Visual Basic.NET Working with Menus and Dialog Boxes Week 14 Tariq Aziz and Kevin Jones."— Presentation transcript:

1 Compunet Corporation Programming with Visual Basic.NET Working with Menus and Dialog Boxes Week 14 Tariq Aziz and Kevin Jones

2 Compunet Corporation Overview Add menus to your program Process menu choices using program code Use the OpenFileDialog and ColorDialog controls to display special purpose dialog boxes

3 Compunet Corporation Creating Menus During Design Main menus are created during the design stage with the MainMenu component The MainMenu component allows you to do the following: –Create new menus and menu bars –Add new menu items to existing menus –Modify the properties of menus and menu items via the Properties window –Create event handlers to handle the Click event and other events for menu items

4 Compunet Corporation Creating Menus During Design

5 Compunet Corporation To create main menus at design time In the Toolbox, add a MainMenu component to the form by double- clicking the MainMenu tool Type the text for the first menu item, add additional menu items until the structure of your menu is complete.

6 Compunet Corporation To create main menus at design time In the Properties window, set any menu-item properties that you want to change

7 Compunet Corporation To create main menus at design time In the Properties window of the form, make sure that the Menu property is set to the menu you want to display

8 Compunet Corporation Separating Menu Items To create a separator bar on your menu –Select the menu item that represents where you want to place a separator. –Type a hyphen (-). At run time, this hyphen will be displayed as a separator bar.

9 Compunet Corporation Assign an access key To assign an access key to a menu item: –In the designer, click the menu item to which you want to assign an access key. –Type an ampersand (&) in front of the desired letter for the access key.

10 Compunet Corporation Using Menu Item Events You can create event handlers for menu items in the same way that you create event handlers for other controls The most frequently used event is the Click event. The Click event handler should contain the code to be executed when the menu item is clicked. This code will also execute when a shortcut key combination is pressed.

11 Compunet Corporation Using Menu Item Events The Select event is raised when a menu item is highlighted, either with the mouse or with access keys. You might create an event handler that provides detailed help regarding use of a menu command when selected.

12 Compunet Corporation Using Menu Item Events The Popup event is raised just before a menu item’s list is displayed. You can use this event to enable and disable menu items at run time. MenuItem1.Enabled = False

13 Compunet Corporation Displaying Check Marks on Menu Items You can use the Checked property to display a check mark next to a menu item. ' Checks the menu item MenuItem1.Checked = True ' Unchecks the menu item MenuItem1.Checked = False

14 Compunet Corporation To assign a shortcut key Select the menu item for which you want to enable a shortcut key. In the Properties window, select the Shortcut property. Choose the appropriate shortcut key combination from the drop-down menu.

15 Compunet Corporation Dialog Boxes Controls OpenFileDialog SaveFileDialog FontDialog ColorDialog PrintDialog PrintViewDialog PageSetupDialog

16 Compunet Corporation OpenFileDialog Control Click and drag OpenFileDialog controls to the form. You can find them on component tray


Download ppt "Compunet Corporation Programming with Visual Basic.NET Working with Menus and Dialog Boxes Week 14 Tariq Aziz and Kevin Jones."

Similar presentations


Ads by Google