AddCommandBar Method
Collapse the table of content
Expand the table of content

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

 

Creates a command bar that is saved and available the next time the environment is started.

Namespace:   EnvDTE
Assembly:  EnvDTE (in EnvDTE.dll)

object AddCommandBar(
	string Name,
	vsCommandBarType Type,
	object CommandBarParent,
	int Position = 1
)

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. An Office 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.

The CommandBar object is a member of the Microsoft Office object model.

The command bar added with this method is a permanent command bar, which is available in every session of the IDE whether or not the VSPackage is loaded. You should use this method to add a command bar only if you want a permanent command bar. You should call this method only once, when your VSPackage is loaded for the first time. If you want a temporary command bar, which appears only when the VSPackage is actually loaded, you must use the DTE.CommandBars.Add method when you load the VSPackage, and then call DTE.CommandBars.Remove method when it is unloaded.

Since a permanent command bar appears even when the VSPackage is not loaded, you should be sure to remove it when the VSPackage is uninstalled. Therefore, you must use an MSI to install and uninstall your VSPackage, and add a custom action to your uninstall program.

For more information about menus and commands, see Commands, Menus, and Toolbars.

Return to top
Show:
© 2016 Microsoft