Share via


Managing the Toolbox

The Visual Studio SDK allows a VSPackage, such as an editor or designer, to manage the membership and appearance of the Toolbox.

In addition, The Toolbox itself can be managed using automation. For more information on managing a Toolbox through automation, see How to: Control the Toolbox.

Automatic Toolbox Tab Selection

A particular Toolbox tab or category can be automatically made active based on which editor or designer is currently active. For example, if a forms designer is activated, you may want the All Windows Forms tab selected.

This support is limited to editors and designers requiring:

  1. The implementation of a factory object to provide instances of the editor or designer. For more information on implementing a designer or editor factory object, see Editor Factories.

  2. Registration of the toolbox tab that automatically is activated if the editor or designer is present.

Controlling the Toolbox

Supplementing automation support, the Visual Studio SDK provides the following interfaces to provide VSPackages greater control over how the Toolbox is managed.

Interface Description
IToolboxService Allows applications to manage, add, and remove ToolboxItem objects from the Toolbox. Also enables configuration of appearance and Toolbox categories.
IVsToolbox2 Allows applications to manage, add, and remove Active-based Toolbox controls, as well as configure Toolbox categories and appearance.
IVsToolbox3 Extends functionality found in IVsToolbox2 by providing complete support for persistence and localization.
IVsToolbox4
IVsToolbox5
IVsToolbox6

There are several important points to keep in mind when working with these interfaces:

  • IToolboxService is available only to Managed Package Framework-based VSPackages.

  • Controls cannot be directly added to the Toolbox using IToolboxService.

  • A VSPackage must either use IVsToolbox2 to add controls or host the control in a wrapper control that derives from AxHost.

    Visual Studio provides the Aximp.exe tool for automating the wrapping of an ActiveX control in a control derived from AxHost. For more information, see Aximp.exe (Windows Forms ActiveX Control Importer).

  • IVsToolbox, IVsToolbox2, and IVsToolbox3 are COM-based interfaces available through the interop assemblies.

  • IVsToolbox2 derives from IVsToolbox and implements all its methods.

    Objects only obtain an instance of IVsToolbox2.

  • IVsToolbox3 does not derive from IVsToolbox2 and does not implement its methods.

    Objects needing functionality in both interfaces must obtain instances of both interfaces from the environment.

  • When working with IVsToolbox2 and IVsToolbox3, information about the canonical (non-localized) names of tabs is handled by the GetIDOfTab and SetIDOfTab methods.

  • When using IToolboxService, it is up to the implementer to manage localized information, such as names of categories.

    Use the settings mechanism to enable users to save Toolbox settings accessed by users from the Import/Export Settings command, found on the IDE's Tools menu. For more information on how to use settings, see Extending User Settings and Options.

See Also

Extending the Toolbox