次の方法で共有


ProvideToolboxFormatAttribute Class

Apply this attribute to classes implementing VSPackages to declare that the VSPackage provides Toolbox items with the specified clipboard format and to enable drag-and-drop support in the Visual Studio Toolbox.

Inheritance Hierarchy

System.Object
  System.Attribute
    Microsoft.VisualStudio.Shell.ProvideToolboxFormatAttribute

Namespace:  Microsoft.VisualStudio.Shell
Assembly:  Microsoft.VisualStudio.Shell.11.0 (in Microsoft.VisualStudio.Shell.11.0.dll)

Syntax

'宣言
<AttributeUsageAttribute(AttributeTargets.Class, Inherited := True, AllowMultiple := True)> _
Public NotInheritable Class ProvideToolboxFormatAttribute _
    Inherits Attribute
[AttributeUsageAttribute(AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
public sealed class ProvideToolboxFormatAttribute : Attribute

The ProvideToolboxFormatAttribute type exposes the following members.

Constructors

  Name Description
Public method ProvideToolboxFormatAttribute Initializes a new instance of ProvideToolboxFormatAttribute for the specified format.

Top

Properties

  Name Description
Public property Format Gets the name of a supported clipboard format.
Public property TypeId When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.)

Top

Methods

  Name Description
Public method Equals Infrastructure. Returns a value that indicates whether this instance is equal to a specified object. (Inherited from Attribute.)
Public method GetHashCode Returns the hash code for this instance. (Inherited from Attribute.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method IsDefaultAttribute When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class. (Inherited from Attribute.)
Public method Match When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.)
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Explicit Interface Implementations

  Name Description
Explicit interface implemetationPrivate method _Attribute.GetIDsOfNames Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfo Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.GetTypeInfoCount Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.)
Explicit interface implemetationPrivate method _Attribute.Invoke Provides access to properties and methods exposed by an object. (Inherited from Attribute.)

Top

Remarks

Attribute Context

Applies to

Classes providing VSPackages by implementing the IVsPackage interface or the Package interface.

Repeatable

Yes

Required attributes

ProvideToolboxItemsAttribute

Invalid attributes

None

This attribute is used only for registration purposes and does not affect runtime behavior.

Apply this attribute to classes implementing a VSPackage that either provides Toolbox items with a non-standard clipboard format or does not support one or more the default Toolbox clipboard formats.

A VSPackage without this attribute must support all default Toolbox clipboard types.

For a list of the default Toolbox clipboard types supported by a VSPackage, see Toolbox (Visual Studio SDK).

Use of this attribute by itself does not register a VSPackage as a provider of items with a given clipboard. An instance of the attribute must be applied to register the VSPackage as providing objects of the specified format.

Only one clipboard format is registered as supported for each instance of this attribute applied to a class. To indicate that multiple formats are supported, multiple instances of the attribute must be applied to the class.

Note   C# automatically appends the word "Attribute" to the name of any attribute class. In C# code, refer to this attribute as ProvideToolboxFormat.

Examples

In the example below the attributes applied to the MyPackage class indicates that it supports version 1 of Toolbox items 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

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

Microsoft.VisualStudio.Shell Namespace

ProvideToolboxFormatAttribute

Other Resources

Toolbox (Visual Studio SDK)