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


Sample: Add a custom menu created in .NET to ArcGIS for Desktop (ArcObjects .NET 10.4 SDK)

Add a custom menu created in .NET to ArcGIS for Desktop


PurposeThis sample demonstrates how to create a base or root-level menu with submenu functionality. The root-level menu is created by inheriting the BaseMenu class from the ESRI.ArcGIS.ADF.Local assembly's ESRI.ArcGIS.ADF namespace and by implementing the ESRI.ArcGIS.Framework.IRootLevelMenu interface. The submenu functionality is created by using existing ArcGIS functionality that is accessed by the class identifier (CLSID) and ProgID in ArcMap. Additionally, a custom command is created and is accessed as a submenu. This sample contains all of the code demonstrated in the Adding a custom menu created in .NET to ArcGIS for Desktop walkthrough.

How to use

See How to use ArcGIS samples for help on compiling, setting up the debugger, and 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.

Add and use menu and submenu commands in ArcMap
  1. Open and compile the solution in Visual Studio.
  2. Start ArcMap.
  3. Click the Customize menu and click Customize Mode. The Customize dialog box appears.
  4. Click the Commands tab, and in the Categories area, scroll down and click [Menus].
  5. In the Commands area, click My_Menu and drag it onto the ArcMap graphical user interface (GUI) in the menu bar area.
  6. Click Close. You can now access the functionality on your custom menu and submenu items. See the following screen shots:

    Screen shot of the Customize dialog box.


    Screen shot of the My_Menu command in ArcMap.

MyBaseMenu.cs Demonstrates the creation of a root-level menu and the addition of submenu ArcObjects functionality.
AddShapefile.cs Demonstrates the creation of a custom command to add shapefiles to the ActiveView used as a submenu.
Download the C# files
MyBaseMenu.vb Demonstrates the creation of a root-level menu and the addition of submenu ArcObjects functionality.
AddShapefile.vb Demonstrates the creation of a custom command to add shapefiles to the ActiveView used as a submenu.
Download the VB.NET files

Download the files for all languages

See Also:

Walkthrough: Adding a custom menu created in .NET to ArcGIS for Desktop
Creating toolbars and menus
Creating commands and tools




Development licensing Deployment licensing
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced