This document is archived and information here might be outdated. Recommended version. |
Returns the item at the specified index from the ToolbarMenu.
[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
The property is used to access a particular item on the ToolbarMenu. The item at the top of the menu has an index of 0.
1023 800A03FF: The specified index is out of range
To loop through a ToolbarMenus item collection use the GetItem method in conjunction with the Count property.
//Get a toolbar item
IToolbarItem toolbarItem = axToolbarControl1.GetItem(0);
//Get a the menu from the item
IToolbarMenu toolbarMenu = toolbarItem.Menu;
if (toolbarMenu == null) return;
toolbarItem = toolbarMenu.GetItem(0); //First Item
toolbarItem = toolbarMenu.GetItem(1); //Second Item
toolbarItem = toolbarMenu.GetItem(toolbarMenu.Count - 1); //Last Item
for (int i=0; i<=toolbarMenu.Count - 1;i++)
{
IToolbarItem toolbarItem = toolbarItem.GetItem(i);
//Do something..
}
'Get a toolbar item
Dim pToolbarItem As IToolbarItem
pToolbarItem = AxToolbarControl1.GetItem(0)
'Get a the menu from the item
Dim pToolbarMenu As IToolbarMenu
pToolbarMenu = pToolbarItem.Menu
If pToolbarMenu Is Nothing Then Exit Sub
pToolbarItem = pToolbarMenu.GetItem(0) 'First Item
pToolbarItem = pToolbarMenu.GetItem(1) 'Second Item
pToolbarItem = pToolbarMenu.GetItem(pToolbarMenu.Count - 1) 'Last Item
Dim i As Long
For i = 0 To pToolbarMenu.Count - 1
pToolbarItem = pToolbarMenu.GetItem(i)
'Do something..
Next i