Compartir a través de


Command.AddControl (Método)

Crea un control de barra de comandos persistente para este comando.

Espacio de nombres:  EnvDTE
Ensamblado:  EnvDTE (en EnvDTE.dll)

Sintaxis

'Declaración
Function AddControl ( _
    Owner As Object, _
    Position As Integer _
) As Object
Object AddControl(
    Object Owner,
    int Position
)
Object^ AddControl(
    [InAttribute] Object^ Owner, 
    [InAttribute] int Position
)
abstract AddControl : 
        Owner:Object * 
        Position:int -> Object 
function AddControl(
    Owner : Object, 
    Position : int
) : Object

Parámetros

  • Owner
    Tipo: System.Object
    Obligatorio.Objeto CommandBar al que se agregará el nuevo control de la barra de comandos.
  • Position
    Tipo: System.Int32
    Opcional.Posición del índice, a partir de uno, en la barra de comandos donde se colocará el nuevo control.

Valor devuelto

Tipo: System.Object
Objeto CommandBarControl.

Comentarios

El entorno guarda el control y su posición, haciendo que esté disponible según los ContextUIGUIDs del comando o sus respuestas para QueryStatus Method durante cada nueva sesión del entorno, independientemente de que el complemento esté cargado o no.

Ejemplos

' Macro code.
Imports Microsoft.Office.Core
Sub AddControlExample()
   ' Before running, you must add a reference to
   ' Microsoft.VisualStudio.CommandBars. Also, 
   ' for this example to work correctly, there should be an add-in 
   ' available in the Visual Studio environment.
   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")

   ' Create a toolbar and add the File.NewFile command to it.
   cmdbarobj = cmds.AddCommandBar("MyCmdBar", vsCommandBarType.vsCommandBarTypeToolbar)
   MsgBox("Commandbar name: " & cmdbarobj.Name)
   cmdobj.AddControl(cmdbarobj)
   cmds.AddNamedCommand(colAddins.Item(1), "MyCommand", "Button Text", "Some tooltip", True)
End Sub

Seguridad de .NET Framework

Vea también

Referencia

Command Interfaz

EnvDTE (Espacio de nombres)