+ All Categories
Home > Documents > VB .net tutorial - 9

VB .net tutorial - 9

Date post: 15-Nov-2014
Category:
Upload: mathes99994840202
View: 888 times
Download: 7 times
Share this document with a friend
Popular Tags:
36
Creating Menus and Working with MDI Applications ©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 1 of 36 Objectives In this lesson, you will learn to: Create menus and submenus Create an MDI application Create toolbars Create context menus Add a status bar to a Windows Application Form
Transcript
Page 1: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 1 of 36

Objectives

In this lesson, you will learn to:

Create menus and submenus

Create an MDI application

Create toolbars

Create context menus

Add a status bar to a Windows Application Form

Page 2: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 2 of 36

Menus in Visual Basic .NET

Help in enhancing the user interface of an application.

Offer a convenient and consistent way to organize related options into a group.

Are of two types:

Menus that appear on the menu bar.

Context menus, which appear when the right mouse button is clicked.

Page 3: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 3 of 36

Menus that appear on the menu bar

Are created using the MainMenu object, which is a collection of MenuItem objects that are used to add individual menu items to the menu bar.

Can be added either at the design time or at run time.

Context Menus

Contain the most frequently used menu options.

Can be added to a form either at design time or at run time.

Page 4: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 4 of 36

MDI Applications

Allow you to display multiple windows at the same time, with each form sharing a parent‑child relationship.

Consist of MDI parent forms and MDI child forms.

Require an MDI parent form to be created either at design time or at run time by setting the IsMdiContainer

property of the form to true.

Page 5: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 5 of 36

Just a Minute…

1. How can you specify a Windows Form to be a MDI Parent form?

2. Fill in the blank:

______________ objects are added to the ____________ collection to include menu options to a Windows form.

Page 6: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 6 of 36

Problem Statement 9.D.1

The data entry application at the call centers of Diaz Telecommunications should enable users to access multiple data entry forms. To allow easy access to different data entry forms, the data entry application should provide a user-friendly interface. It should also allow users to access the monthly sales report for data analysis. In addition, the users should be able to exit the data entry application when required. The forms that the users at the call centers of Diaz Telecommunications should be able to access are Customer Details form, Employee Details form, and Order Details form.

Page 7: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 7 of 36

Task List

Identify the objects to be integrated.

Identify the mechanism to integrate the objects.

Design the required integration.

Perform the appropriate steps to integrate the application.

Save the application.

Run the application and access the options.

Page 8: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 8 of 36

Task 1: Identify the objects to be integrated.

Result:

As per the problem statement, you need to integrate four data entry forms and the monthly sales report. You also need to provide an Exit option to users.

Page 9: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 9 of 36

Task 2: Identify the mechanism to integrate the objects.

Result:

As per the problem statement, you need to integrate the Customer Details, Employee Details, and Order Details forms and the monthly sales report so that the users at Diaz

Telecommunications can access the forms and the report using a single data entry application.

To integrate these forms and the report, you need to create an MDI application. The MDI application will have a

single MDI Parent form and four MDI Child forms to display the data entry forms in separate windows. You also need to add menus to the MDI parent form to enable users to switch between the forms.

Page 10: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 10 of 36

Task 2: Identify the mechanism to integrate the objects. (Contd.)

Purpose Name Text Level Grouped Under

Data Entry Forms mnudataentryforms &Data Entry Forms 1

Customer Details mnucustomer &Customer Details 2 mnudataentryforms

Order Details mnuorder &Order Details 2 mnudataentryforms

Employee Details mnuemployee &Employee Details 2 mnudataentryforms

Report mnureports &Report 1  

Monthly Sales Report

mnumonthlyreport & Monthly Sales Report

2 mnureports

Quit the application mnuexit E&xit 1  

Page 11: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 11 of 36

Task 3: Design the required integration.

Result:

The menus can be organized as given below:

Page 12: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 12 of 36

Task 4: Perform the appropriate steps to integrate the application.

Task 5: Save the application.

Task 6: Run the application.

Page 13: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 13 of 36

Just a Minute…

In an MDI application, you need to ensure that when the Product menu option is clicked, the Product form is displayed. Complete the code to display the Product form.

Page 14: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 14 of 36

Problem Statement 9.D.2

The users at the call centers of Diaz Telecommunications frequently need to access the Customer Details form, the Order Details forms, and the Exit options. Therefore, the Data Entry Application project should enable users to access these options easily.

Page 15: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 15 of 36

Task List

Identify the technique to provide easy access to menu items.

Identify the menu items frequently accessed.

Perform the appropriate steps to provide easy access.

Save the application.

Run the application and access the options.

Page 16: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 16 of 36

Task 1: Identify the technique to provide easy access to menu items.

Result:

You should use context menus to provide easy access to menu items.

Page 17: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 17 of 36

Task 2: Identify the menu items frequently accessed.

Result:

As per the problem statement, the Customer Details form, the Order Details form, and the Exit options are

frequently accessed.

Page 18: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 18 of 36

Task 3: Perform the appropriate steps to provide easy access.

Task 4: Save the application.

Task 5: Run the application and access the options.

Page 19: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 19 of 36

Just a Minute…

You have added a ContextMenu control to a Windows form. The ContextMenu control has the default name ContextMenu1. You have added three MenuItems named Product, Customer, and Sales to the ContextMenu1. How would you ensure that the MenuItems added to the ContextMenu1 would be displayed when a user right-clicks the Windows form?

Page 20: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 20 of 36

Problem Statement 9.P.1

The users at the call centers of Diaz Telecommunications should be able use an application that can integrate the Customer Details form, the Order Details form, and the Employee Details form. The application should also provide options to access the daily sales report and invoke the Print dialog box. In addition, the users should easily be able to terminate the application. The application should also include options to access the Order Details form and terminate the application quickly.

Page 21: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 21 of 36

Toolbar

Is a graphical alternative to a menu.

Contains buttons that provide quick access to the most frequently used options in an application.

Can be created in a Windows application by adding the ToolBar control to a Windows Form.

Page 22: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 22 of 36

Problem Statement 9.D.3

The users at the call centers of Diaz Telecommunications access the Customer Details, the Order details and the Exit options frequently. To facilitate quick access to these options, provide users with a graphical interface.

Page 23: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 23 of 36

Task List

Identify the menu options most frequently used.

Identify a mechanism to provide graphical access.

Perform the appropriate steps to provide easy access.

Save the application.

Run the application.

Page 24: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 24 of 36

Task 1: Identify the menu options most frequently used.

Result:

As per the problem statement, the Customer Details, Order details and Exit options are most frequently accessed.

Page 25: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 25 of 36

Task 2: Identify a mechanism to provide graphical access.

Result:

A toolbar provides easy access to the frequently used menu options.

Page 26: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 26 of 36

Task 3: Perform the appropriate steps to provide easy access.

Task 4: Save the application.

Task 5: Run the application.

Page 27: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 27 of 36

Just a Minute…

1. Fill in the blank:

You can add buttons to a ToolBar control by accessing the _____________________ Editor.

Page 28: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 28 of 36

Just a Minute… (Contd.)

2. You have added a toolbar control and an ImageList control to the form, Form1. You have added four buttons to the ToolBar1 and four .bmps to the ImageList1.You need to specify the images for each of the ToolBar buttons based on the following table:

ToolBar Button Name ImageName Position of the image in the ImageList collection

TbProduct ProductImage 0

TbCustomer CustomerImage 1

TbSales SalesImage 2

TbExit ExitImage 3

Page 29: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 29 of 36

Problem Statement 9.D.4

While entering details about the customers, orders, and employees, the users at Diaz Telecommunications should be provided with some information about the data to be entered in the controls. Update the Data Entry Application project to reflect the requirement.

Page 30: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 30 of 36

Task List

Identify the information to be displayed.

Identify the mechanism to display the required information.

Perform the appropriate steps to display the information.

Save the application.

Run the application and view the information.

Page 31: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 31 of 36

Task 1: Identify the information to be displayed.

Result:

As per the problem statement, the relevant information for each data entry form needs to be displayed.

Page 32: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 32 of 36

Task 2: Identify the mechanism to display the required information.

The StatusBar Control

Is typically displayed at the bottom of an application window and is used to display information about the current state of the application.

Has panels that can display individual pieces of information.However, you need to set the ShowPanels property of the StatusBar control to true to use multiple panels in the status bar.

Can also contain text to display informative messages, such as the use of the displayed form in an MDI application.

Page 33: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 33 of 36

Task 2: Identify the mechanism to display the required information. (Contd.)

Result:

You should use a status bar to display the relevant information about the data entry forms.

Page 34: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 34 of 36

Task 3: Perform the appropriate steps to display the information.

Task 4: Save the application.

Task 5: Run the application and view the information.

Page 35: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 35 of 36

Just a Minute…

1. Fill in the blank:

The _______ property of the StatusBar enables you to specify the message that will be displayed in the StatusBar panel.

2. You have added a panel in the StatusBar1. How would you ensure that the panel size gets adjusted based on the size of the text it will hold?

Page 36: VB .net tutorial - 9

Creating Menus and Working with MDI Applications

©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 36 of 36

Summary

In this lesson, you learned that:

MDI applications enable you to integrate different parts of an application.

Menus are used to provide a user-friendly interface for accessing options.

Context menus enable users to access the most frequently used options.

The ToolBar control enables the use of graphical objects to access the most frequently used options.

The ImageList control can be used to add images to the ToolBar control.

The StatusBar control can be used to display relevant information about the application.


Recommended