Commands Interface

Definition

Contains all of the commands in the environment, as Command objects.

public interface class Commands : System::Collections::IEnumerable
[System.Runtime.InteropServices.Guid("E6B96CAC-B8C7-40AE-B705-5C81878C4A9E")]
[System.Runtime.InteropServices.TypeLibType(4160)]
public interface Commands : System.Collections.IEnumerable
[System.Runtime.InteropServices.Guid("E6B96CAC-B8C7-40AE-B705-5C81878C4A9E")]
public interface Commands : System.Collections.IEnumerable
[<System.Runtime.InteropServices.Guid("E6B96CAC-B8C7-40AE-B705-5C81878C4A9E")>]
[<System.Runtime.InteropServices.TypeLibType(4160)>]
type Commands = interface
    interface IEnumerable
[<System.Runtime.InteropServices.Guid("E6B96CAC-B8C7-40AE-B705-5C81878C4A9E")>]
type Commands = interface
    interface IEnumerable
Public Interface Commands
Implements IEnumerable
Derived
Attributes
Implements

Examples

Imports Microsoft.VisualStudio.CommandBars  
Sub CommandsExample()  
   ' Before running, you must add a reference to the Office   
   ' typelib to gain access to the CommandBar object.  
   Dim cmds As Commands  
   Dim cmdobj As Command  
   Dim customin, customout As Object  
   Dim cmdbarobj As CommandBar  
   Dim colAddins As AddIns  

   ' Set references.  
   colAddins = DTE.AddIns()  
   cmds = DTE.Commands  
   cmdobj = cmds.Item("File.NewFile")  

   ' Execute the File.NewFile command.  
   cmds.Raise(cmdobj.Guid, cmdobj.ID, customin, customout)  

   ' Create a toolbar and add the File.NewFile command to it.  
   cmdobj = cmds.Item("File.NewFile")  
   cmdbarobj = cmds.AddCommandBar("Mycmdbar", _  
     vsCommandBarType.vsCommandBarTypeToolbar)  
   cmdobj.AddControl(cmdbarobj)  
   ' Show the command bar and its button.  
   cmdbarobj.Visible = True  
End Sub  

Properties

Count

Gets a value indicating the number of objects in the Commands collection.

DTE

Gets the top-level extensibility object.

Parent

Gets the immediate parent object of a Commands collection.

Methods

Add(String, Int32, Object)

Microsoft Internal Only.

AddCommandBar(String, vsCommandBarType, Object, Int32)

Creates a command bar that is saved and available the next time the environment is started.

AddNamedCommand(AddIn, String, String, String, Boolean, Int32, Object[], Int32)
Obsolete.

Creates a named command that is saved by the environment and made available the next time the environment starts, even if the VSPackage is not loaded on environment startup.

Add-ins are now deprecated. For more information, see FAQ: Converting Add-ins to VSPackage Extensions.

CommandInfo(Object, String, Int32)

Returns the command GUID and ID associated with the given Microsoft.VisualStudio.CommandBars.CommandBar control.

GetEnumerator()

Returns an enumerator for items in the Commands collection.

Item(Object, Int32)

Returns the indexed Command object.

Raise(String, Int32, Object, Object)

Executes the specified command.

RemoveCommandBar(Object)

Removes a command bar that was created with the AddCommandBar(String, vsCommandBarType, Object, Int32) method.

Applies to