ContextMenu

From Visual WebGui Wiki

Jump to: navigation, search


Contents

Overview

The ContextMenu control is functionally equivialent to the Windows Forms ContextMenu control and serves the purpose to provide you with shortcut menus or context sensitve menus that you can attach to your controls and access via right mouse click on the control. ContextMenu fairly resembles the MainMenu control, which is for use as the menu structure on your mainform.

There is a vital difference between how events are used between on ContextMenu versus MainMenu. On MainMenu, the events on the MainMenu control itself fire, but on the ContextMenu, no event on the ContextMenu control itself fires. Instead, the control you attach the ContextMenu to has a MenuClick event, that is used for event handling of ContextMenu related events. This means that you don't attach any event handlers to the ContextMenu control itself.

Each ContextMenu has a MenuItems collection, which is a collection of zero or more MenuItem controls, representing the items on the menu. Each MenuItem has it's own MenuItems collection, thus supporting a multilvel menu structure.

Availability

The ContextMenu is one of the Out of the Box standard controls, which means it is free and available in all Visual WebGui versions.

Relevant members

Properties

Name
Description
MenuItems
Collection of MenuItem controls representing the items on the ContextMenu
MenuItem.MenuItems
Collection of MenuItem controls for the MenuItem, representing further sublevels of the menu structure
MenuItem.Text
The text that will show on the menu for this MenuItem
MenuItem.Tag

Tag is a user definable storage, for storing whatever we like to store. It can contain any object type. Most often it is used to store a string or numerical value, for the procedure handling the MenuClick event to know what MenuItem was selected.

It can however be used to store any value, which could even be used as an address to a function to handle the processing when that item is selected on the menu.


Methods

Name
Description
Update
Used to refresh the control after some programmatic changes have been made.


Events

Name Description
MenuClick
This event is not used in Visual WebGui
PopUp


Samples of use

Tips and Tricks

No event fires on ContextMenu - use MenuClick event on control

As mentioned in the overview, there is no menu related event that fires in VisualWebGui on the ContextMenu control. Instead, you use the MenuClick event of the various controls you attach your ContextMenu to.

Same ContextMenu - multiple Controls

The same ContextMenu instance can be used for multiple Controls and no changes are needed on the ContextMenu to support that.

SDK Version highlights

See also

Rererences

Other references


Personal tools