This documentation is archived and is not being maintained.

DesignerAttribute Class

Specifies the class used to implement design-time services for a component.

For a list of all members of this type, see DesignerAttribute Members.


[Visual Basic]
<AttributeUsage(AttributeTargets.Class Or _
NotInheritable Public Class DesignerAttribute
   Inherits Attribute
[AttributeUsage(AttributeTargets.Class |
public sealed class DesignerAttribute : Attribute
[AttributeUsage(AttributeTargets::Class |
public __gc __sealed class DesignerAttribute : public Attribute
   AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface)
class DesignerAttribute extends Attribute

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.


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.


[Visual Basic, C#, C++] 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.

[Visual Basic] 
<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

[Designer("System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL", 
public class MyForm : ContainerControl {
    // Insert code here.

[Designer(S"System.Windows.Forms.Design.DocumentDesigner, System.Windows.Forms.Design.DLL", 
__gc class MyForm : public ContainerControl {
    // Insert code here.

[Visual Basic, C#, C++] 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.

[Visual Basic] 
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 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 = 
    Console.WriteLine("The designer for this class is: " + myAttribute.DesignerTypeName);
    return 0;

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 = 
    Console::WriteLine(S"The designer for this class is: {0}", myAttribute->DesignerTypeName);

    return 0;

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.ComponentModel

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System (in System.dll)

See Also

DesignerAttribute Members | System.ComponentModel Namespace | Attribute