DesignerAttribute Class
Assembly: System (in system.dll)
[AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Interface, AllowMultiple=true, Inherited=true)] public sealed class DesignerAttribute : Attribute
/** @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
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", typeof(IRootDesigner)), DesignerCategory("Form")] public class MyForm : ContainerControl { // Insert code here. }
/** @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 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 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.<?xml version="1.0" encoding="utf-16"?>
<Classes xmlns="http://schemas.microsoft.com/VisualStudio/2004/03/SmartDevices/XMTA.xsd">
<Class Name="DeviceControlsLibrary.DeadlyControl">
<Designer>
<Type>DeviceControlDesignersLibrary.DeadlyControlDesigner, DeviceControlDesignersLibrary,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</Type>
<BaseType>System.ComponentModel.Design.IDesigner, System, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</BaseType>
</Designer>
</Class>
</Classes>
The <Type> tag is your control's type (with namespace), followed by the fully qualified assembly name. The BaseType should be used as shown here.
You can find more information on this topic in this article: http://dvanderboom.wordpress.com/2008/03/14/compact-framework-creating-custom-controls-and-designers-part-1/