Weitere ähnliche Inhalte
Ähnlich wie Vb net xp_09 (20)
Kürzlich hochgeladen (20)
Vb net xp_09
- 1. Creating Menus and Working with MDI Applications
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
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 1 of 36
- 2. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 2 of 36
- 3. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 3 of 36
- 4. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 4 of 36
- 5. Creating Menus and Working with MDI Applications
Just a Minute…
2. How can you specify a Windows Form to be a MDI Parent
form?
3. Fill in the blank:
______________ objects are added to the
____________ collection to include menu options to a
Windows form.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 5 of 36
- 6. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 6 of 36
- 7. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 7 of 36
- 8. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 8 of 36
- 9. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 9 of 36
- 10. Creating Menus and Working with MDI Applications
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 mnudataentryform
s
Order Details mnuorder Order Details 2 mnudataentryform
s
Employee Details mnuemployee Employee Details 2 mnudataentryform
s
Report mnureports Report 1
Monthly Sales mnumonthlyreport Monthly Sales 2 mnureports
Report Report
Quit the application mnuexit Exit 1
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 10 of 36
- 11. Creating Menus and Working with MDI Applications
Task 3: Design the required integration.
Result:
The menus can be organized as given below:
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 11 of 36
- 12. Creating Menus and Working with MDI Applications
Task 4: Perform the appropriate steps to integrate
the application.
Task 5: Save the application.
Task 6: Run the application.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 12 of 36
- 13. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 13 of 36
- 14. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 14 of 36
- 15. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 15 of 36
- 16. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 16 of 36
- 17. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 17 of 36
- 18. Creating Menus and Working with MDI Applications
Task 3: Perform the appropriate steps to provide
easy access.
Task 4: Save the application.
Task 5: Run the application and access the options.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 18 of 36
- 19. Creating Menus and Working with MDI Applications
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?
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 19 of 36
- 20. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 20 of 36
- 21. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 21 of 36
- 22. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 22 of 36
- 23. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 23 of 36
- 24. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 24 of 36
- 25. Creating Menus and Working with MDI Applications
Task 2: Identify a mechanism to provide graphical
access.
Result:
A toolbar provides easy access to the frequently used menu
options.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 25 of 36
- 26. Creating Menus and Working with MDI Applications
Task 3: Perform the appropriate steps to provide
easy access.
Task 4: Save the application.
Task 5: Run the application.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 26 of 36
- 27. Creating Menus and Working with MDI Applications
Just a Minute…
2. Fill in the blank:
You can add buttons to a ToolBar control by accessing
the _____________________ Editor.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 27 of 36
- 28. Creating Menus and Working with MDI Applications
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
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 28 of 36
- 29. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 29 of 36
- 30. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 30 of 36
- 31. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 31 of 36
- 32. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 32 of 36
- 33. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 33 of 36
- 34. Creating Menus and Working with MDI Applications
Task 3: Perform the appropriate steps to display the
information.
Task 4: Save the application.
Task 5: Run the application and view the information.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 34 of 36
- 35. Creating Menus and Working with MDI Applications
Just a Minute…
2. Fill in the blank:
The _______ property of the StatusBar enables you to
specify the message that will be displayed in the
StatusBar panel.
4. 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?
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 35 of 36
- 36. Creating Menus and Working with MDI Applications
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.
©NIIT Creating Menus and Working with MDI Applications/Lesson 9/Slide 36 of 36