This document is archived and information here might be outdated. Recommended version. |
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
);
[C++] Parameters index [in]
index is a parameter of type long
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.
1023 800a03ff: The specified index is out of range
To loop through a ToolbarPalette item collection use the GetItem method in conjunction with the Count property.
//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..
}
'Get a toolbar item
Dim
toolbarItemAs
IToolbarItem2 toolbarItem = AxToolbarControl1.GetItem(0)'Get the palette from the item
Dim
toolbarPaletteAs
IToolbarPalette toolbarPalette = toolbarItem.PaletteIf
toolbarPaletteIs 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
iAs Long For
i = 0To
toolbarPalette.Count - 1 toolbarItem = toolbarPalette.GetItem(i)'Do something..
Next
i