When a menu system is created at design time,
the programmer can control property settings
for menu items. After these properties are set,
they can be altered at runtime to assist the
user in interpreting which selections have been
made, which items are turned on, and which commands
are available.
To dynamically alter the appearance of a menu
system, the menu object is referenced along
with the desired property to be altered. This
syntax is the same for regular controls found
on a VB form. The following sections explore
the syntax used in setting menu properties.
The following code assumes that Form1 has
a complete menu system already defined. The
View menu has a sub-menu item called Toolbar.
This menu item is having the Checked property
set to true to indicate the toolbar is visible
(see the result in Figure 3.4):
mnuViewToolbar.Checked = True
This code uses the same syntax that other
objects use: the object name, a period separator,
followed by the property to be set, and then
the value after the assignment operator.

FIGURE 3.4 - Sample menu with properties
that change at runtime.
The following code demonstrates more menu
objects and their property settings:
mnuViewStatusBar.Checked = True
mnuFileOpen.Enabled = False
mnuFormatFontBold.Checked = True
mnuPopUp.Visible = False
In these examples, notice how the use of the
menu naming convention helps decipher which
menu is to be affected. The object name starts
with the mnu prefix followed by the top-level
menu item named View, followed by the sub-level
menu item, StatusBar. This ensures easy readability
when going through source code.
Altering application menus at design time
is not very different from controlling other
objects. The one difficulty that programmers
have with menus is remembering to control both
the user interface and the menus. The interface
can always be seen, but menus must first be
opened to view their states. One common technique
used to assist with maintaining a consistent
interface is to call a procedure.
The procedure will perform the required actions and affect both the interface
and required information. This allows various menus to call the same code and
keep the program flow easier to follow.