Walkthrough: Adding a Toolbar to the IDE
This walkthrough shows how to add a toolbar to the Visual Studio integrated development environment (IDE).
A toolbar is a horizontal or vertical strip that contains buttons that are bound to commands. Depending on its implementation, a toolbar in the IDE can be repositioned, docked on any side of the main IDE window, or made to stay in front of other windows.
In addition, users can add commands to a toolbar or remove them from it by using the Customize dialog box. Typically, toolbars in VSPackages are user-customizable. The IDE handles all customization, and the VSPackage responds to commands. The VSPackage does not have to know where a command is physically located.
For more information about menus, see Commands, Menus, and Toolbars.
The Visual Studio Package project template is available in three locations in the New Project dialog box:
Under Visual Basic Extensibility. The default language of the project is Visual Basic.
Under C# Extensibility. The default language of the project is C#.
Under Other Project Types Extensibility. The default language of the project is C++.
This section demonstrates how to use the Visual Studio Package project template to create a VSPackage that supports a toolbar that has just one menu command.
To create the toolbar VSPackage
Create a VSPackage named IDEToolbar. For more information, see Walkthrough: Creating a Menu Command By Using the Visual Studio Package Template.
In the Visual Studio Package template, set the programming language to Visual Basic or Visual C#, select Menu Command, set the command name to Toolbar Test Command, and set the command ID to cmdidTestCmd.
To create a toolbar for the IDE
Open IDEToolbar.vsct in the text editor.
The toolbar definition is located here because the VSCT parser does not distinguish between menus and toolbars at this level.
Add a Menu element to the Menus section to define your toolbar.
Toolbars cannot be nested like submenus. Therefore, you do not have to assign a parent group. Also, you do not have to set a priority, because the user can move toolbars. Typically, initial placement of a toolbar is defined programmatically, but subsequent changes by the user are persisted.
By default, if a toolbar has no commands, it does not appear.
On the Build menu, click Build Solution. Correct any errors that might occur.
Press F5 to open the experimental Visual Studio in debug mode.
Right-click the IDE menu bar, and then click Test Toolbar on the list of toolbars.
When you click the icon on the new toolbar, the message "Inside Company.Toolbar.ToolbarPackage.MenuItemCallback()" should be displayed.