New to the .NET framework is the concept of attribute-based development. Attributes provide an extensibility mechanism for classes, properties, methods, parameters, and return values. By applying attributes to a particular entity, the default behavior can be altered to produce a new desired result. For a complete description of attributes, refer to the MSDN help.
The .NET designer architecture makes heavy use of attributes to simplify common development tasks. Examples include defining the default value for a property, assigning a category and description to properties, and indicating the default event for a control, to name a few. No discussion of the designer architecture would be complete without a list of attributes commonly used for designers, controls, serialization, licensing, and the PropertyGrid. Table 5.12 lists the attributes found in the System.ComponentModel namespace, along with descriptions.
Table 5.12. System.ComponentModel Attributes
| Attribute | Description |
| AmbientValueAttribute | The value for this property originates for another source, generally the containing control. |
| BrowsableAttribute | Used by the PropertyGrid to determine whether the property should be displayed. |
| CategoryAttribute | Defines the category for the property or event within the PropertyTab of the PropertyGrid. |
| DefaultEventAttribute | Defines the default event for the component. |
| DefaultPropertyAttribute | Defines the default property for a component. |
| DefaultValueAttribute | Defines the default value for a property. |
| DescriptionAttribute | Defines the description for the property or event. |
| DesignerAttribute | Identifies the designer for the specified component. |
| DesignerCategoryAttribute | Defines the category for the designer. |
| DesignerSeralizationVisibiltyAttribute | Specifies how the designer should serialize a property. |
| DesignOnlyAttribute | Specifies that the property is available only at design-time. |
| EditorAttribute | Specifies the UITypeEditor for the component property. |
| EditorBrowsableAttribute | Specifies whether the property is available to the UITypeEditor. |
| ImmutableObjectAttribute | Specifies that the component has no editable properties. |
| LicenseProviderAttribute | Specifies the LicenseProvider for the class. |
| ListBindableAttribute | Specifies a list can be used for data binding. |
| LocalizableAttribute | Localization for a property. |
| MergablePropertyAttribute | Specifies that a property can be combined with properties of other objects in the property window. |
| NotifyParentPropertyAttribute | Specifies that the parent property should be notified when the property is modified. |
| ParenthesizePropertyNameAttribute | Specifies that the property value should appear within a set of parentheses. Example: (Collection) appears next to collection-based properties such as the Tabs property of the Tab control. |
| PropertyTabAttribute | Identifies the property tab(s) to display for the class or classes. |
| ProvidePropertyAttribute | Defines the name of a property provided by the class that implements the IExtenderProvider interface. The ToolTip class is an extender provider. |
| ReadOnlyAttribute | Specifies that the property is read-only within the PropertyGrid. |
| RecommendedAsConfigurableAttribute | Specifies that the property can be used as an application setting. |
| RefreshPropertiesAttribute | Defines how the designer refreshes when the property is modified. |
| ToolboxItemAttribute | Specifies whether the component should be loaded in the toolbox. |
| ToolboxItemFilterAttribute | Specifies that the component will accept only other ToolboxItems belonging to the specified namespace, or type. |
Attributes are a prominent theme in .NET development, and custom control development is no exception.