This document is archived and information here might be outdated. Recommended version. |
ArcObjects Help for .NET developers > ArcObjects namespaces > Controls > ESRI ArcGIS Controls > Interfaces > IT > IToolbarMenu Interface > IToolbarMenu.Find Method (ArcObjects .NET 10.5 SDK) |
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
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.
To find an Item on the ToolbarMenu using a Command implementing ICommandSubType pass a UID with its SubType property set.
//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);
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)