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


IToolbarPalette.GetItem Method (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (Controls)  

IToolbarPalette.GetItem Method

Returns the item at the specified index from the ToolbarPalette.

[Visual Basic .NET]
Public Function GetItem ( _
    ByVal index As Integer _
) As IToolbarItem
[C#]
public IToolbarItem GetItem (
    int index
);
[C++]
HRESULT GetItem(
  long index,
  IToolbarItem** item
);
[C++]

Parameters index [in] index is a parameter of type long item [out, retval]
item is a parameter of type IToolbarItem

Product Availability

Available with ArcGIS Engine.

Description

The property is used to access a particular item on the ToolbarPalette. The item at the top of the menu has an index of 0.

Errors Returned

1023 800a03ff: The specified index is out of range

Remarks

To loop through a ToolbarPalette item collection use the GetItem method in conjunction with the Count property.

[C#]
//Get a toolbar item
IToolbarItem2 toolbarItem=(IToolbarItem2) axToolbarControl1.GetItem(0);

//Get the palette from the item  
IToolbarPalette toolbarPalette=toolbarItem.Palette;
if (toolbarPalette == null) return; 

toolbarItem=(IToolbarItem2) toolbarPalette.GetItem(0);                         //First Item
toolbarItem=(IToolbarItem2) toolbarPalette.GetItem(1);                         //Second Item
toolbarItem=(IToolbarItem2) toolbarPalette.GetItem(toolbarPalette.Count - 1);  //Last Item 

for (int i=0; i<= toolbarPalette.Count-1; i++)
{
  toolbarItem=(IToolbarItem2) toolbarPalette.GetItem(i);
  //do something..  
}
[Visual Basic .NET]

'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

toolbarItem=toolbarPalette.GetItem(0)                              'First Item
toolbarItem=toolbarPalette.GetItem(1)                              'Second Item
toolbarItem=toolbarPalette.GetItem(toolbarPalette.Count - 1)       'Last Item 

Dim i As Long
For i=0 To toolbarPalette.Count - 1
    toolbarItem=toolbarPalette.GetItem(i)
    'Do something..  
Next i

See Also

IToolbarPalette Interface