Objectives: Menus Submenus Common Dialog Context Menus Sub Procedures Function Procedures Call
Objectives: Menus Submenus Common Dialog Context Menus Sub Procedures Function Procedures Call
Objectives
Chapter 5
Menus, Common
Dialog Boxes, Sub
Procedures, and
Function
Procedures
McGraw-Hill
5-2
Copyr ight 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Defining Menus (1 of 2)
Menus
Menu Bar
to
execute a procedure
Menu items are controls with properties and events.
MenuStrip component is
added to a form.
MenuStrip is a container to
w hich ToolStripMenuItems,
ToolStripComboBoxes,
ToolStripSeparators, and
ToolStripTextBoxes can be
added.
5-3
5-4
Defining Menus (2 of 2)
5-5
Enter and change the Text property for each menu and
menu item using the Menu Designer or make the
changes in the Text property using the Properties
window.
5-6
7/31/2014
5-7
5-8
Separator Bars
Submenus
5-9
5-10
Menu Properties
5-11
5-12
7/31/2014
Pointer
ColorDialog
FontBrow serDialog
FontDialog
OpenFileDialog
SaveFileDialog
5-13
5-14
ColorDialog1.ShowDialog( )
FontDialog1.ShowDialog( )
5-15
5-16
FontDialog1.Font = SubTotalLabel.Font or
ColorDialog1.Color = .BackColor
T itleLabel.BackColor = .ColorDialog1.Color
5-17
5-18
7/31/2014
5-19
5-20
5-21
5-22
Sub Procedure
Calling
Procedure
5-23
ByVal value
Sends a copy of the arguments value; original
cannot be altered.
ByRef reference
Sends a reference to the memory location w here
the original is stored and therefore the procedure
may change the arguments value; original can be
altered
If not specified, arguments are passed by value.
5-24
7/31/2014
5-25
5-26
Function Example
5-28
5-29