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

IToolbarMenu2.AddMultiItem Method (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Controls > ESRI ArcGIS Controls > Interfaces > IT > IToolbarMenu2 Interface > IToolbarMenu2.AddMultiItem Method
ArcGIS Developer Help

IToolbarMenu2.AddMultiItem Method

Adds a multi-item to the ToolbarMenu.

[Visual Basic .NET]
Public Function AddMultiItem ( _
    ByVal MultiItem As Object, _
    [ByVal index As Integer], _
    [ByVal beginGroup As Boolean], _
    [ByVal Style As esriCommandStyles] _
) As Integer
public int AddMultiItem (
    object MultiItem,
    int index,
    bool beginGroup,
    esriCommandStyles Style
HRESULT AddMultiItem(
  VARIANT MultiItem,
  long index,
  VARIANT_BOOL beginGroup,
  esriCommandStyles Style
MultiItem [in]

MultiItem is a parameter of type VARIANT index [in, optional, defaultvalue()]
index is a parameter of type long beginGroup [in, optional, defaultvalue()]
beginGroup is a parameter of type bool Style [in, optional, defaultvalue()]
Style is a parameter of type esriCommandStyles

Product Availability

Available with ArcGIS Engine.


Takes the specified multi-item and creates new items that are appended to the ToolbarMenu with their Command set, and returns the index of the first item added. Specifiy the multi-item as either a IUID, ProgID, or IMultiItem. To add a sub menu use the AddSubMenu method.

Index determines the position on the ToolbarMenu that the item will be added to. By default this is -1 and represents the end of the ToolbarMenu.

beginGroup determines whether a separator will appear before the item. By default beginGroup is false.

Style determines the style of the item.

Errors Returned

1023 800a03FF: The specified index is out of range
1073 800a0431: The specified item is not a valid multi-item


AddMultiItem checks to see if the supplied command already exists in the CommandPool used by the ToolbarMenu. If the command does not already exist, it is created and added to the CommandPool with a ICommandPool::UsageCount of 1, and is set as the IToolbarItem::Command. If the command already exists in the CommandPool its ICommandPool::UsageCount is incremented by 1 and the command is set as the IToolbarItem::Command. The ICommand::OnCreate method will be called the first time a command is added to the CommandPool .

Where possible always supply multi-items as either Uid objects or ProgID's. Only supply multi-items  as IMultiItem objects when a IUID or ProgID does not exist, and the class is compiled as part of the same project using the ToolbarControl. Passing a multi-item as IMultiItem object has the following limitation: Multiple instances of the same multi-item can be added to the CommandPool, and each IToolbarItem::Command will point to a different command object.


//Get a toolbar item
IToolbarItem toolbarItem = axToolbarControl1.GetItem(0);
//Get the menu from the item  
IToolbarMenu2 toolbarMenu= (IToolbarMenu2) toolbarItem.Menu;
if (toolbarMenu is NullReferenceException) return; 
//Add the multi-item to the menu

[Visual Basic .NET]

'Get a toolbar item
Dim toolbarItem As IToolbarItem = AxToolbarControl1.GetItem(0)
'Get the menu from the item  
Dim toolbarMenu As IToolbarMenu2 = toolbarItem.Menu
If toolbarMenu Is Nothing Then Exit Sub
'Add the multi-item to the menu
toolbarMenu.AddMultiItem("esriControls.ControlsMapBookmarksMultiItem", -1, False, esriCommandStyles.esriCommandStyleIconAndText)

See Also

IToolbarMenu2 Interface

.NET Samples

Add a custom bookmarks MultiItem to the ToolbarControl