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


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

IToolbarControlDefault.GetItem Method

Returns the item at the specified index from the ToolbarControl.

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

index is a parameter of type long

Product Availability

Available with ArcGIS Engine.

Description

The property is used to access a particular item on the ToolbarControl. The item at the beginning of the collection to the left of the ToolbarControl has an index of 0. Visually items are represented on the ToolbarControl as buttons, tools, menus, text boxes and combo boxes.

Errors Returned

1023 800a03ff: The specified index is out of range

Remarks

To loop through a ToolBarControl's item collection use the GetItem property in conjunction with the Count property.

[C#]
IToolbarItem toolbarItem = axToolbarControl1.GetItem(0);  
toolbarItem = axToolbarControl1.GetItem(1);             
toolbarItem = axToolbarControl1.GetItem(axToolbarControl1.Count - 1);   //Last Item 

//Loop through each item on the ToolbarControl 
for (int i=0;i<=axToolbarControl1.Count - 1;i++)
{
        IToolbarItem toolbarItem = axToolbarControl1.GetItem(0); 
}
[Visual Basic .NET]
Dim pToolbarItem As IToolbarItem
pToolbarItem = AxToolbarControl1.GetItem(0)                       'First Item
pToolbarItem = AxToolbarControl1.GetItem(1)                       'Second Item
pToolbarItem = AxToolbarControl1.GetItem(AxToolbarControl1.Count - 1) 'Last Item 

'Loop through each item on the ToolbarControl 
Dim i As Long
For i = 0 To AxToolbarControl1.Count - 1
    pToolbarItem = AxToolbarControl1.GetItem(i)
    'Do something...  
Next i


See Also

IToolbarControlDefault Interface