Commands2.AddCommandBar Method
Creates a command bar that is saved and available the next time the environment is started.
Namespace: EnvDTE80
Assembly: EnvDTE80 (in EnvDTE80.dll)
Syntax
'Declaration
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
Parameters
- Name
Type: System.String
Required. A name for the new command bar.
- Type
Type: EnvDTE.vsCommandBarType
Required. A vsCommandBarType constant that determines the type of command bar:
- CommandBarParent
Type: System.Object
Optional. A CommandBar object to which the new command bar is to be added. (This is required, however, if Type is vsCommandBarTypeMenu.)
- Position
Type: System.Int32
Optional. The index position, starting at one, in the command bar to place the new command bar.
Return Value
Type: System.Object
A CommandBar object.
Implements
Commands.AddCommandBar(String, vsCommandBarType, Object, Int32)
Remarks
The new command bar is available during each new session of the environment regardless of whether the Add-in is loaded.
Examples
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
.NET Framework Security
- 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.