DesignerAttribute 类 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定用于为组件实现设计时服务的类。
public ref class DesignerAttribute sealed : Attribute[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)]
public sealed class DesignerAttribute : Attribute[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Interface, AllowMultiple=true, Inherited=true)>]
type DesignerAttribute = class
    inherit AttributePublic NotInheritable Class DesignerAttribute
Inherits Attribute- 继承
- 属性
示例
以下示例创建一个名为 的 MyForm类。 
              MyForm 具有两个属性,一个 DesignerAttribute 指定此类使用 DocumentDesigner的 ,一个 DesignerCategoryAttribute 指定类别的 Form 。
[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL",
IRootDesigner::typeid),
DesignerCategory("Form")]
ref class MyForm: public ContainerControl{
   // Insert code here.
};
[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL", 
    typeof(IRootDesigner)),
    DesignerCategory("Form")]
public class MyForm : ContainerControl {
    // Insert code here.
}
<Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL", _
    GetType(IRootDesigner)), DesignerCategory("Form")> _
Public Class MyForm
    
    Inherits ContainerControl
    ' Insert code here.
End Class
下一个示例创建 的 MyForm实例。 然后,它获取 类的属性,提取 DesignerAttribute,并打印设计器的名称。
int main()
{
   // Creates a new form.
   MyForm^ myNewForm = gcnew MyForm;
   // Gets the attributes for the collection.
   AttributeCollection^ attributes = TypeDescriptor::GetAttributes( myNewForm );
   /* Prints the name of the designer by retrieving the DesignerAttribute
       * from the AttributeCollection. */
   DesignerAttribute^ myAttribute = dynamic_cast<DesignerAttribute^>(attributes[ DesignerAttribute::typeid ]);
   Console::WriteLine( "The designer for this class is: {0}", myAttribute->DesignerTypeName );
   return 0;
}
public static int Main() {
    // Creates a new form.
    MyForm myNewForm = new MyForm();
 
    // Gets the attributes for the collection.
    AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewForm);
 
    /* Prints the name of the designer by retrieving the DesignerAttribute
     * from the AttributeCollection. */
    DesignerAttribute myAttribute = 
       (DesignerAttribute)attributes[typeof(DesignerAttribute)];
    Console.WriteLine("The designer for this class is: " + myAttribute.DesignerTypeName);
  
    return 0;
}
Public Shared Function Main() As Integer
    ' Creates a new form.
    Dim myNewForm As New MyForm()
    
    ' Gets the attributes for the collection.
    Dim attributes As AttributeCollection = TypeDescriptor.GetAttributes(myNewForm)
    
    ' Prints the name of the designer by retrieving the DesignerAttribute
    ' from the AttributeCollection. 
    Dim myAttribute As DesignerAttribute = _
        CType(attributes(GetType(DesignerAttribute)), DesignerAttribute)
    Console.WriteLine(("The designer for this class is: " & myAttribute.DesignerTypeName))
    
    Return 0
End Function 'Main
注解
用于设计时服务的类必须实现 IDesigner 接口。
DesignerBaseTypeName使用 属性查找设计器的基类型。 DesignerTypeName使用 属性获取与此成员关联的设计器类型的名称。
有关更多信息,请参阅特性。
构造函数
| DesignerAttribute(String) | 使用提供设计时服务的类型的名称初始化 DesignerAttribute 类的新实例。 | 
| DesignerAttribute(String, String) | 使用设计器类型和设计器的基类初始化 DesignerAttribute 类的新实例。 | 
| DesignerAttribute(String, Type) | 使用设计器类的名称和设计器的基类初始化 DesignerAttribute 类的新实例。 | 
| DesignerAttribute(Type) | 使用提供设计时服务的类型初始化 DesignerAttribute 类的新实例。 | 
| DesignerAttribute(Type, Type) | 使用设计器类型和设计器基类的类型初始化 DesignerAttribute 类的新实例。 | 
属性
| DesignerBaseTypeName | 获取此设计器的基类型名。 | 
| DesignerTypeName | 获取与此设计器特性关联的设计器类型名。 | 
| TypeId | 获取此特性类型的唯一 ID。 | 
方法
| Equals(Object) | 返回给定对象的值是否等于当前的 DesignerAttribute。 | 
| GetHashCode() | 返回此实例的哈希代码。 | 
| GetType() | 获取当前实例的 Type。(继承自 Object) | 
| IsDefaultAttribute() | 在派生类中重写时,指示此实例的值是否是派生类的默认值。(继承自 Attribute) | 
| Match(Object) | 当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。(继承自 Attribute) | 
| MemberwiseClone() | 创建当前 Object 的浅表副本。(继承自 Object) | 
| ToString() | 返回表示当前对象的字符串。(继承自 Object) | 
显式接口实现
| _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) | 将一组名称映射为对应的一组调度标识符。(继承自 Attribute) | 
| _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) | 检索对象的类型信息,然后可以使用该信息获取接口的类型信息。(继承自 Attribute) | 
| _Attribute.GetTypeInfoCount(UInt32) | 检索对象提供的类型信息接口的数量(0 或 1)。(继承自 Attribute) | 
| _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) | 提供对某一对象公开的属性和方法的访问。(继承自 Attribute) |