Sdílet prostřednictvím


Commands2.AddCommandBar – metoda (String, vsCommandBarType, Object, Int32)

Vytvoří panel příkazů, která je uložena a budou k dispozici při příštím spuštění prostředí.

Obor názvů:  EnvDTE80
Sestavení:  EnvDTE80 (v EnvDTE80.dll)

Syntaxe

'Deklarace
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

Parametry

  • Name
    Typ: System.String
    Povinné.Název nového panelu příkazů.
  • Position
    Typ: System.Int32
    Nepovinné.Pozice indexu od jednoho panelu příkaz umístit nový panel příkazů.

Vrácená hodnota

Typ: System.Object
A CommandBar objektu.

Implementuje

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

Poznámky

Nový panel příkazů je k dispozici během každou novou relaci prostředí bez ohledu na to, zda doplněk načten.

Příklady

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

Zabezpečení rozhraní .NET Framework

Viz také

Odkaz

Commands2 Rozhraní

AddCommandBar – přetížení

EnvDTE80 – obor názvů