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


IToolbarPalette.Find Method (ArcObjects .NET 10.5 SDK)
ArcObjects Library Reference (Controls)  

IToolbarPalette.Find Method

Returns the index of the first item containing the given command. 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 ToolbarPalette using the specified IUid, ProgID, ICommand. If the specified command cannot be found -1 is returned.

Remarks

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

[C#]

long lindex;
UID uID;
      
//Get a toolbar item
IToolbarItem2 toolbarItem=(IToolbarItem2) axToolbarControl1.GetItem(0);
//Get the palette from the item  
IToolbarPalette toolbarPalette=toolbarItem.Palette;
if (toolbarPalette == null) return; 

//Find an Item on the palette by passing a ProgID
lIndex=toolbarPalette.Find("esriControls.ControlsMapZoomInTool");

//Find an Item on the palette by passing a UID
uID=new UIDClass();
uID.Value="esriControls.ControlsMapZoomInTool";
lIndex=toolbarPalette.Find(uID);

//Find an Item on the palette by passing a UID with subtype set
uID=new UIDClass();
uID.Value="esriControls.ControlsInkHighlightTool";
uID.SubType=2;
lIndex=toolbarPalette.Find(uID);

[Visual Basic .NET]

Dim lIndex As Long, uID As UID

'Get a toolbar item
Dim toolbarItem As IToolbarItem2
toolbarItem=AxToolbarControl1.GetItem(0)
'Get the palette from the item  
Dim toolbarPalette As IToolbarPalette
toolbarPalette=toolbarItem.Palette
If toolbarPalette Is Nothing Then Exit Sub

'Find an Item on the palette by passing a ProgID
lIndex=toolbarPalette.Find("esriControls.ControlsMapZoomInTool")

'Find an Item on the palette by passing a UID
uID=New UIDClass
uID.Value="esriControls.ControlsMapZoomInTool"
lIndex=toolbarPalette.Find(uID)

'Find an Item on the palette by passing a UID with subtype set
uID=New UIDClass
uID.Value="esriControls.ControlsInkHighlightTool"
uID.SubType=2
lIndex=toolbarPalette.Find(uID)

See Also

IToolbarPalette Interface