Use context menu


Purpose
This sample demonstrates how to create a popup menu using the Toolbar control in conjunction with the Map control and the control commands.
 
The AddItem method is used in the Form_Load event to add new items to the Toolbar control with their style set. An IMenuDef object is created from a menu defined in the same application. The menu is defined in a class implementing the IMenuDef interface and is made up of default Toolbar control commands. This MenuDef is added to a ToolbarMenu using the AddItem method, and the ToolbarMenu Hook property is set to the Toolbar control. In the Map control OnMouseDown event, the PopupMenu method is used to display the toolbar menu when the right mouse button is clicked.

How to use

See How to use ArcGIS samples for help on running the sample.

  1. Run the UseContextMenu application.
  2. Open a map document.
  3. Right-click the map document to display a context menu.

If you installed the samples feature, you will find the files associated with this sample in <Your Developer Kit install location>\DeveloperKit10.4\Java\Samples\ArcObjects.

toolbarbean/UseContextMenu.java Main class




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