DesignerAttribute Class
Assembly: System (in system.dll)
'Declaration <AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Interface, AllowMultiple:=True, Inherited:=True)> _ Public NotInheritable Class DesignerAttribute Inherits Attribute 'Usage Dim instance As DesignerAttribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple=true, Inherited=true) */ public final class DesignerAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple=true, Inherited=true) public final class DesignerAttribute extends Attribute
Not applicable.
The class you use for the design-time services must implement the IDesigner interface.
Use the DesignerBaseTypeName property to find the designer's base type. Use the DesignerTypeName property to get the name of the type of designer associated with this member.
For more information, see Attributes Overview and Extending Metadata Using Attributes.
The following example creates a class called MyForm. MyForm has two attributes, a DesignerAttribute that specifies this class uses the DocumentDesigner, and a DesignerCategoryAttribute that specifies the Form category.
<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
/** @attribute Designer("System.Windows.Forms.Design.DocumentDesigner,"+
"System.Windows.Forms.Design.DLL", IRootDesigner.class)
@attribute DesignerCategory("Form")
*/
public static class MyForm extends ContainerControl
{
// Insert code here.
} //MyForm
The next example creates an instance of MyForm. Then it gets the attributes for the class, extracts the DesignerAttribute, and prints the name of the designer.
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
public static void main(String[] args)
{
// 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.get_Item(DesignerAttribute.class.ToType()));
Console.WriteLine(("The designer for this class is: "
+ myAttribute.get_DesignerTypeName()));
} //main
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.