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


IToolbarMenu.Find Method (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (Controls)  

IToolbarMenu.Find Method

Returns the index of the first item containing the given command or menu. Returns -1 if it is not found.

[Visual Basic .NET]
Public Function Find ( _
    ByVal item As Object _
) As Integer
[C#]
public int Find (
    object item
);
[C++]
HRESULT Find(
  VARIANT item,
  long* pVal
);
[C++]

Parameters item [in] item is a parameter of type VARIANT pVal [out, retval] pVal is a parameter of type long

Product Availability

Available with ArcGIS Engine.

Description

Returns the index of the first item on the ToolbarMenu using the specified IUid , ProgID, ICommand or IToolbarMenu. If the specified comman, menu or palette cannot be found -1 is returned.

Remarks

To find an Item on the ToolbarMenu using a Command implementing ICommandSubType pass a UID with its SubType property set.

[C#]
//Get a toolbar item
IToolbarItem toolbarItem=axToolbarControl1.GetItem(0);
//Get a the menu from the item  
IToolbarMenu toolbarMenu=toolbarItem.Menu;
if (toolbarMenu == null) return; 

//Find an Item on the menu by passing a UID
IUID uID=new UIDClass();
uID.Value="esriControls.ControlsMapFullExtentCommand";
long lIndex=toolbarMenu.Find(uID);

//Find an Item on the menu by passing a ProgID
string progID="esriControls.ControlsMapViewMenu";
lIndex=toolbarMenu.Find(progID);

//Find an Item on the menu by passing a UID with subtype set
IUID uID=new UIDClass();
uID.Value="esriControls.ControlsMapFullExtentCommand";
uID.SubType=2;
lIndex=toolbarMenu.Find(uID);
[Visual Basic .NET]
Dim lIndex As Long
'Get a Toolbar item
Dim pToolbarItem As IToolbarItem
pToolbarItem=AxToolbarControl1.GetItem(0)
'Get a the menu from the item  
Dim pToolbarMenu As IToolbarMenu
pToolbarMenu=pToolbarItem.Menu
If pToolbarMenu Is Nothing Then Exit Sub

'Find an Item on the menu by passing a UID
Dim pUid As New UIDClass
pUid.Value="esriControls.ControlsMapFullExtentCommand"
lIndex=pToolbarMenu.Find(pUid)

'Find an Item on the menu by passing a ProgID
Dim sProgID As String
sProgID="esriControls.ControlsMapViewMenu"
lIndex=pToolbarMenu.Find(sProgID)

'Find an Item on the menu by passing a UID with subtype set
Dim pUid As New UIDClass
pUid.Value="MyCommandSubTypes.MyCommands"
pUid.SubType=2
lIndex=pToolbarMenu.Find(pUid)

See Also

IToolbarMenu Interface