To create a pop-up menu, a top-level menu item
is used. This item can be part of the normal
menu structure seen by the user, or it can have
its Visible property set to False so that it
does not appear with the regular menu(as shown
in Figure 3.5).
All items on the pop-up menu are created as
sub-level items of the invisible top-level menu.
Each sub-menu item can have its properties set
When the pop-up menu is needed, the PopupMenu
method is called to activate the pop-up menu.
The following code demonstrates this:
FIGURE 3.5. design time view of menu system
with a pop-up menu.
This preceding code calls the PopupMenu method
of Form1, as shown in Figure 3.6. The menu item
mnuPopUp1 is passed as an argument and is displayed
at the current mouse location. This code assumes
that a menu system has been created and a menu
item named mnuPopUp1 exists.
The PopupMenu method accepts the name of the
menu to activate, arguments that indicate the
orientation of the menu (left, center, and right),
and the screen coordinates for display and other
FIGURE 3.6 - Runtime view of a custom pop-up menu.