Compartir a través de


Commands2.AddCommandBar (Método) (String, vsCommandBarType, Object, Int32)

Crea una barra de comandos que se guarda y está disponible la próxima vez que se inicia el entorno.

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

Sintaxis

'Declaración
Function AddCommandBar ( _
    Name As String, _
    Type As vsCommandBarType, _
    CommandBarParent As Object, _
    Position As Integer _
) As Object
Object AddCommandBar(
    string Name,
    vsCommandBarType Type,
    Object CommandBarParent,
    int Position
)
Object^ AddCommandBar(
    [InAttribute] String^ Name, 
    [InAttribute] vsCommandBarType Type, 
    [InAttribute] Object^ CommandBarParent, 
    [InAttribute] int Position
)
abstract AddCommandBar : 
        Name:string * 
        Type:vsCommandBarType * 
        CommandBarParent:Object * 
        Position:int -> Object 
function AddCommandBar(
    Name : String, 
    Type : vsCommandBarType, 
    CommandBarParent : Object, 
    Position : int
) : Object

Parámetros

  • Name
    Tipo: System.String
    Obligatorio.Nombre de la nueva barra de comandos.
  • Position
    Tipo: System.Int32
    Opcional.Posición del índice, a partir de uno, en la barra de comandos donde se colocará la nueva barra de comandos.

Valor devuelto

Tipo: System.Object
Objeto CommandBar.

Implementaciones

Commands.AddCommandBar(String, vsCommandBarType, Object, Int32)

Comentarios

La nueva barra de comandos estará disponible durante cada sesión nueva del entorno sin importar si está cargado o no el complemento.

Ejemplos

Imports Microsoft.VisualStudio.CommandBars
Sub AddCommandBarExample()
   ' Before running, you must add a reference to the Office 
   ' typelib to gain access to the CommandBar object. 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 = cmds.AddNamedCommand(colAddins.Item(1), "mycommand", "mycommand", "tooltip for mycommand", True)
End Sub

Seguridad de .NET Framework

Vea también

Referencia

Commands2 Interfaz

AddCommandBar (Sobrecarga)

EnvDTE80 (Espacio de nombres)