Add a custom bookmarks MultiItem to the ToolbarControl


Purpose
This sample demonstrates creating a MultiItem and adding it to a ToolbarMenu. The MultiItem creates a menu item for each spatial bookmark that exists in the bookmarks collection of the focus map. The sample uses the ToolbarControl in conjunction with the MapControl and Control commands.

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.

  1. Browse to a map document to load into the MapControl.
  2. Navigate around the data using the commands on the ToolbarControl.
  3. Zoom to any bookmark listed on the spatial bookmark menu.
  4. Create a new bookmark based on the current extent of the focus map.

Additional information

An IMultiItem object is created from a MultiItem defined in the same application. The MultiItem is defined in a class implementing the IMenuDef interface. The IMultiItem.OnPopup function determines the number of menu items to be created and returns the number of bookmarks in the focus maps bookmark collection. The IMultiItem.ItemCaption property sets each menu item caption to ISpatialBookmark.Name and the IMultiItem.OnItemClick event zooms to the bookmark with the ISpatialBookmark.ZoomTo method.
A new ToolbarMenu is created and the IToolbarMenu2.AddMultiItem method is used to add the spatial bookmarks MultiItem to the ToolbarMenu. A create bookmarks custom command defined in the application is also added to the ToolbarMenu using the IToolbarMenu2.AddItem method. The IToolbarControl.AddItem method is used in the Form_Load event to add the ToolbarMenu and some control commands to the ToolbarControl with their style set.


AssemblyInfo.cs Assembly information.
MultiItemBookmarks.cs Form file.
Bookmark.cs Form file.
CreateBookmark.cs Class file.
SpatialBookmarks.cs Class file.
Download the C# files
AssemblyInfo.vb Assembly information.
MultiItemBookmarks.vb Form file.
CreateBookmark.vb Class file.
SpatialBookmarks.vb Class file.
Download the VB.NET files

Download the files for all languages

See Also:

ToolbarControl class
IToolbarControl interface
IToolbarMenu2 interface
IMultiItem interface
How to create dynamic menu commands using a MultiItem




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