Create toolbar menu


Purpose
This sample demonstrates how to create a toolbar menu item and a submenu on this item 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. A button can then be used to create an IMenuDef object from a menu defined in the same application. The menu is then added to the toolbar. The menu is defined in a class implementing the IMenuDef interface and is made up of default Toolbar control commands. Another button can be used to add a submenu to the menu that was just created.

How to use

See How to use ArcGIS samples for help on running the sample. If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

  1. Run the CreateNewToolbarMenu application.
  2. Open a map document.
  3. Click the Add Menu button on the RHS panel. A menu is added to the toolbar.
  4. Click the Add Sub Menu button. A submenu is added to the toolbar menu that was created in step 3.


Download the files for Java
toolbarbean/CreateNewToolbarMenu.java Sample source file.




Development licensing Deployment licensing
Engine Developer Kit Engine Runtime
ArcView
ArcEditor
ArcInfo