DefaultPropertyAttribute Class
Specifies the default property for a component.
Assembly: System (in System.dll)
Use the Name property to get the name of the default property.
For more information, see Attributes Overview and Extending Metadata Using Attributes.
The following example defines a control named MyControl. The class is marked with a DefaultPropertyAttribute that specifies MyProperty as the default property.
The next example creates an instance of MyControl. Then it gets the attributes for the class, extracts the DefaultPropertyAttribute, and prints the name of the default property.
public static int Main() { // Creates a new control. MyControl myNewControl = new MyControl(); // Gets the attributes for the collection. AttributeCollection attributes = TypeDescriptor.GetAttributes(myNewControl); /* Prints the name of the default property by retrieving the * DefaultPropertyAttribute from the AttributeCollection. */ DefaultPropertyAttribute myAttribute = (DefaultPropertyAttribute)attributes[typeof(DefaultPropertyAttribute)]; Console.WriteLine("The default property is: " + myAttribute.Name); return 0; }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.