Creates a persistent command bar control for the command.
Assembly: EnvDTE (in EnvDTE.dll)
- Type: System.Object
Required. A CommandBar object to which the new command bar control is to be added.
- Type: System.Int32
Optional. The index position, starting at one, in the command bar to place the new control.
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.