次の方法で共有


ProvideToolboxItemsAttribute Class

Apply this attribute to classes implementing VSPackages to declare if they offer a set of items to the Visual Studio Toolbox.

Namespace:  Microsoft.VisualStudio.Shell
Assemblies:   Microsoft.VisualStudio.Shell (in Microsoft.VisualStudio.Shell.dll)
  Microsoft.VisualStudio.Shell.10.0 (in Microsoft.VisualStudio.Shell.10.0.dll)
  Microsoft.VisualStudio.Shell.9.0 (in Microsoft.VisualStudio.Shell.9.0.dll)

Syntax

'宣言
<AttributeUsageAttribute(AttributeTargets.Class, Inherited := True)> _
Public Class ProvideToolboxItemsAttribute _
    Inherits RegistrationAttribute
'使用
Dim instance As ProvideToolboxItemsAttribute
[AttributeUsageAttribute(AttributeTargets.Class, Inherited = true)]
public class ProvideToolboxItemsAttribute : RegistrationAttribute
[AttributeUsageAttribute(AttributeTargets::Class, Inherited = true)]
public ref class ProvideToolboxItemsAttribute : public RegistrationAttribute
[<AttributeUsageAttribute(AttributeTargets.Class, Inherited = true)>]
type ProvideToolboxItemsAttribute =  
    class
        inherit RegistrationAttribute
    end
public class ProvideToolboxItemsAttribute extends RegistrationAttribute

Remarks

Attribute Context

Applies to

Classes providing VSPackages by implementing IVsPackage, Package.

Repeatable

No

Required attributes

ProvideToolboxFormatAttribute

Invalid attributes

None

Apply the attribute ProvideToolboxItemsAttribute to a Package-derived class or a class that implements IVsPackage that is required to enable support for users to drag data objects of this format, provided by the class, onto the Toolbox. This implementing class must handle the drop notifications itself.

This attribute is only used for registration purposes and does not affect how code behaves at runtime.

Depending on the arguments provided to its constructor, a ProvideToolboxFormatAttribute can be used to indicate that a VSPackage does not provide any Toolbox items. For more information about the attribute constructor, see #ctor(). If the attribute ProvideToolboxFormatAttribute is applied to a class to indicate that it provides Toolbox items, one or more instances of ProvideToolboxFormatAttribute must also be applied.

The ProvideToolboxItemsAttribute class uses the instances of ProvideToolboxFormatAttribute to properly register a VSPackage as providing Toolbox items of a given format.

If the instance ProvideToolboxItemsAttribute applied to a VSPackage specifies that Toolbox items are provided, the VSPackage must handle the ToolboxInitialized and ToolboxUpgraded events.

Any VSPackage using the ProvideToolboxItemsAttribute attribute must provide a handler for ToolboxInitialized and ToolboxUpgraded event

Examples

In the example below the attributes applied to the class MyPackage indicates that it supports version 1 of Toolbox items of with two clipboard formats "CF_XMLCODE" and "InPlaceMenuEditorMenu".

    [DefaultRegistryRoot("Software\\Microsoft\\VisualStudio\\8.0")]
    [ProvideToolboxItems(true, 1)]
    [ProvideToolboxFormat("CF_XMLCODE")]
    [ProvideToolboxFormat("InPlaceMenuEditorMenu")]
    [Guid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX")]
    internal sealed class MyPackage : Package

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.VisualStudio.Shell.RegistrationAttribute
      Microsoft.VisualStudio.Shell.ProvideToolboxItemsAttribute

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ProvideToolboxItemsAttribute Members

Microsoft.VisualStudio.Shell Namespace