Partilhar via


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

Cria uma barra de comando é salvas e estarão disponíveis na próxima vez em que o ambiente é iniciado.

Namespace:  EnvDTE80
Assembly:  EnvDTE80 (em EnvDTE80.dll)

Sintaxe

'Declaração
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
    Obrigatório.Um nome para a nova barra de comando.
  • Position
    Tipo: System.Int32
    Opcional.A posição de índice, começando em uma, na barra de comando para colocar a nova barra de comando.

Valor de retorno

Tipo: System.Object
A CommandBar objeto.

Implementações

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

Comentários

A nova barra de comando está disponível durante a cada nova sessão do ambiente, independentemente se o suplemento é carregado.

Exemplos

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

Segurança do .NET Framework

Consulte também

Referência

Commands2 Interface

Sobrecargas AddCommandBar

Namespace EnvDTE80