Partager via


Command.AddControl, méthode

Crée un contrôle de barre de commandes persistant pour la commande.

Espace de noms :  EnvDTE
Assembly :  EnvDTE (dans EnvDTE.dll)

Syntaxe

'Déclaration
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

Paramètres

  • Owner
    Type : System.Object
    Obligatoire.Objet CommandBar auquel le nouveau contrôle de barre de commandes doit être ajouté.
  • Position
    Type : System.Int32
    Facultatif.Position d'index (à partir de 1) où placer le nouveau contrôle dans la barre de commandes.

Valeur de retour

Type : System.Object
Objet CommandBarControl.

Notes

L'environnement enregistre le contrôle et son positionnement, en le rendant disponible d'après la commande ContextUIGUIDs ou ses réponses à QueryStatus Method pendant chaque nouvelle session de l'environnement, indépendamment de si le Complément est chargé.

Exemples

' 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

Sécurité .NET Framework

Voir aussi

Référence

Command Interface

EnvDTE, espace de noms