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


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

public object AddCommandBar (string Name, EnvDTE.vsCommandBarType Type, object CommandBarParent, int Position = 1);
abstract member AddCommandBar : string * EnvDTE.vsCommandBarType * obj * int -> obj
Public Function AddCommandBar (Name As String, Type As vsCommandBarType, Optional CommandBarParent As Object, Optional Position As Integer = 1) As Object
String String String

Required. A name for the new command bar.

vsCommandBarType vsCommandBarType vsCommandBarType

Required. A vsCommandBarType constant that determines the type of command bar:

Object Object Object

Optional. An Office CommandBar object to which the new command bar is to be added. (This is required, however, if Type is vsCommandBarTypeMenu.)

Int32 Int32 Int32

Optional. The index position, starting at one, in the command bar to place the new command bar.



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.

Applies to