This document is archived and information here might be outdated. Recommended version. |
ArcObjects namespaces > Controls > ESRI ArcGIS Controls > Interfaces > IT > IToolbarControl2 Interface > IToolbarControl2.GetItem Method (ArcObjects .NET 10.4 SDK) |
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,
IToolbarItem** item
);
[C++]
Parameters index [in] index is a parameter of type long item [out, retval]
item is a parameter of type IToolbarItem
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.
1023 800a03ff: The specified index is out of range
To loop through a ToolBarControl's item collection use the GetItem property in conjunction with the Count property.
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);
}
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