Export (0) Print
Expand All

Commands Interface

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

Namespace:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

public interface Commands extends IEnumerable

The Commands type exposes the following members.

  NameDescription
Public propertyCountGets a value indicating the number of objects in the Commands collection.
Public propertyDTEGets the top-level extensibility object.
Public propertyParentGets the immediate parent object of a Commands collection.
Top

  NameDescription
Public methodAddInfrastructure. Microsoft Internal Only.
Public methodAddCommandBarCreates a command bar that is saved and available the next time the environment is started.
Public methodAddNamedCommandCreates a named command that is saved by the environment and made available the next time the environment starts, even if the Add-in is not loaded on environment startup.
Public methodCommandInfoReturns the command GUID and ID associated with the given Microsoft.VisualStudio.CommandBars.CommandBar control.
Public methodGetEnumeratorReturns an enumerator for items in the Commands collection.
Public methodItemReturns the indexed Command object.
Public methodRaiseExecutes the specified command.
Public methodRemoveCommandBarRemoves a command bar that was created with the AddCommandBar method.
Top

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

Community Additions

ADD
Show:
© 2014 Microsoft