This document is archived and information here might be outdated.  Recommended version.


Enabling menu tracking on the ToolbarControl (ArcObjects .NET 10.6 SDK)
ArcObjects Help for .NET developers > Developing with ArcGIS > Building stand-alone applications > Using the Winforms ArcGIS Engine controls > Using the ToolbarControl > Enabling menu tracking on the ToolbarControl (ArcObjects .NET 10.6 SDK)

Enabling menu tracking on the ToolbarControl


Summary
This topic shows how to display menu items when the mouse pointer is over a ToolbarMenu on the ToolbarControl; this is known as menu tracking. This topic also shows how to create a ToolbarMenu.

In this topic


About enabling menu tracking on the ToolbarControl

When MenuTracking is true, the ToolbarControl automatically displays menu items as the mouse pointer is moved over the ToolbarMenu. This is typical behavior for the main menu bar of an application. See the following code example:
[C#]
axToolbarControl1.MenuTracking=true;
[VB.NET]
AxToolbarControl1.MenuTracking=True
When MenuTracking is false, clicking a black arrow on the ToolbarMenu will display the menu items. This it typical behavior when a ToolbarControl contains both menu items and command items.

Adding and creating menus

To add an existing menu to the ToolbarControl, use AddMenuItem and pass the ProgID of the existing menu.
To create a ToolbarMenu in the application, set its Caption property, add command or tool items to it, then add the menu to the ToolbarControl using AddMenuItem.
See the following code example:
[C#]
//Add existing menus to ToolbarControl.
axToolbarControl1.AddMenuItem("esriControls.ControlsMapViewMenu",  - 1, false, 0);
axToolbarControl1.AddMenuItem("esriControls.ControlsFeatureSelectionMenu",  - 1,
    false, 0);
//Create a new file menu.
IToolbarMenu toolbarMenu=new ToolbarMenuClass();
toolbarMenu.Caption="Map Document";
toolbarMenu.AddItem("esriControls.ControlsOpenDocCommand",  - 1, 0, false,
    esriCommandStyles.esriCommandStyleIconAndText);
toolbarMenu.AddItem("esriControls.ControlsSaveAsDocCommand",  - 1, 1, false,
    esriCommandStyles.esriCommandStyleIconAndText);
axToolbarControl1.AddMenuItem(toolbarMenu,  - 1, false, 0);
[VB.NET]
'Add existing menus to ToolbarControl.
AxToolbarControl1.AddMenuItem("esriControls.ControlsMapViewMenu", -1, False, 0)
AxToolbarControl1.AddMenuItem("esriControls.ControlsFeatureSelectionMenu", -1, False, 0)
'Create a new file menu.
Dim pToolbarMenu As IToolbarMenu
pToolbarMenu=New ToolbarMenuClass
pToolbarMenu.Caption="Map Document"
pToolbarMenu.AddItem("esriControls.ControlsOpenDocCommand", , 0, False, esriCommandStyles.esriCommandStyleIconAndText)
pToolbarMenu.AddItem("esriControls.ControlsSaveAsDocCommand", , 1, False, esriCommandStyles.esriCommandStyleIconAndText)
AxToolbarControl1.AddMenuItem(pToolbarMenu, -1, False, 0)


See Also:

ToolbarControl class
IToolbarControl interface
IToolbarMenu interface




Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced