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


ICommandPool.Command Property (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > ArcObjects namespaces > Controls > ESRI ArcGIS Controls > Interfaces > IC > ICommandPool Interface > ICommandPool.Command Property
ArcGIS Developer Help

ICommandPool.Command Property

The command at the given index.

[Visual Basic .NET]
Public Function get_Command ( _
    ByVal index As Integer _
) As ICommand
[C#]
public ICommand get_Command (
    int index
);
[C++]
HRESULT get_Command(
  long index,
  ICommand** pVal
);
[C++]
Parameters
index [in]

index is a parameter of type long pVal [out, retval]
pVal is a parameter of type ICommand**

Product Availability

Available with ArcGIS Engine.

Description

Returns the command at the specified index in the CommandPool. The index is related to the order commands are added to the CommandPool and not to the display order of any IToolbarItem objects using the commands.

Errors Returned

1023 800a03ff: The specified index is out of range

Remarks

To loop through the CommandPool's command collection use the Command property in conjunction with the Count property.

[C#]

In C# use the get_Command method, as indexed property accessors are not supported.

ICommand command = axToolbarControl1.CommandPool.get_Command(0); //First command
command = axToolbarControl1.CommandPool.get_Command(1);                 //Second command
command = axToolbarControl1.CommandPool.get_Command(axToolbarControl1.CommandPool.Count - 1); //Last command

//Loop through the command collection 
for (int i=0;i<=axToolbarControl1.CommandPool.Count - 1;i++)
{
        command = axToolbarControl1.CommandPool.get_Command(i);
        System.Windows.Forms.MessageBox.Show(command.Name);
}
[Visual Basic .NET]
Dim pCommand As ICommand
pCommand = AxToolbarControl1.CommandPool.Command(0) 'First command
pCommand = AxToolbarControl1.CommandPool.Command(1) 'Second command
pCommand = AxToolbarControl1.CommandPool.Command(AxToolbarControl1.CommandPool.Count - 1) 'Last command

'Loop through the command collection 
Dim i As Long
For i = 0 To AxToolbarControl1.CommandPool.Count - 1
    pCommand = AxToolbarControl1.CommandPool.Command(i)
    System.Windows.Forms.MessageBox.Show(pCommand.Name)
Next i

See Also

ICommandPool Interface

.NET Samples

Dynamic biking Dynamic biking Share a command pool between ToolbarControls