Condividi tramite


Metodo Command.AddControl

Crea un controllo permanente sulla barra dei comandi per il comando.

Spazio dei nomi:  EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

Sintassi

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

Parametri

  • Owner
    Tipo: Object

    Necessario. Oggetto CommandBar al quale deve essere aggiunto il nuovo controllo della barra dei comandi.

  • Position
    Tipo: Int32

    Opzionale. La posizione dell'indice, a partire da 1, nella barra dei comandi in cui deve essere posizionato il nuovo controllo.

Valore restituito

Tipo: Object
Un oggetto CommandBarControl.

Note

L'ambiente salvato il controllo e la relativa posizione, allo disponibile come ContextUIGUIDs di comando quando il componente aggiuntivo di supporto non viene caricato, o delle risposte a QueryStatus Method quando viene caricato.

Esempi

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

Sicurezza di .NET Framework

Vedere anche

Riferimenti

Command Interfaccia

Spazio dei nomi EnvDTE