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


IToolbarControl.GetItem Method (ArcObjects .NET 10.6 SDK)
ArcObjects Library Reference (Controls)  

IToolbarControl.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(i); 
}
[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

IToolbarControl Interface