DescriptionAttribute Class
Specifies a description for a property or event.
System.Attribute
System.ComponentModel.DescriptionAttribute
Microsoft.VisualBasic.Compatibility.VB6.SRDescriptionAttribute
System.Data.DataSysDescriptionAttribute
System.Diagnostics.MonitoringDescriptionAttribute
System.DirectoryServices.DSDescriptionAttribute
System.IO.IODescriptionAttribute
System.Messaging.MessagingDescriptionAttribute
System.ServiceProcess.ServiceProcessDescriptionAttribute
System.Timers.TimersDescriptionAttribute
Assembly: System (in System.dll)
The DescriptionAttribute type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | DescriptionAttribute | Initializes a new instance of the DescriptionAttribute class with no parameters. |
![]() | DescriptionAttribute(String) | Initializes a new instance of the DescriptionAttribute class with a description. |
| Name | Description | |
|---|---|---|
![]() | Description | Gets the description stored in this attribute. |
![]() | DescriptionValue | Gets or sets the string stored as the description. |
![]() | TypeId | When implemented in a derived class, gets a unique identifier for this Attribute. (Inherited from Attribute.) |
| Name | Description | |
|---|---|---|
![]() | Equals | Returns whether the value of the given object is equal to the current DescriptionAttribute. (Overrides Attribute.Equals(Object).) |
![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetHashCode | Returns the hash code for this instance. (Overrides Attribute.GetHashCode.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | IsDefaultAttribute | Returns a value indicating whether this is the default DescriptionAttribute instance. (Overrides Attribute.IsDefaultAttribute.) |
![]() | Match | When overridden in a derived class, returns a value that indicates whether this instance equals a specified object. (Inherited from Attribute.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
| Name | Description | |
|---|---|---|
![]() ![]() | _Attribute.GetIDsOfNames | Maps a set of names to a corresponding set of dispatch identifiers. (Inherited from Attribute.) |
![]() ![]() | _Attribute.GetTypeInfo | Retrieves the type information for an object, which can be used to get the type information for an interface. (Inherited from Attribute.) |
![]() ![]() | _Attribute.GetTypeInfoCount | Retrieves the number of type information interfaces that an object provides (either 0 or 1). (Inherited from Attribute.) |
![]() ![]() | _Attribute.Invoke | Provides access to properties and methods exposed by an object. (Inherited from Attribute.) |
A visual designer can display the specified description when referencing the component member, such as in a Properties window. Call Description to access the value of this attribute.
For more information, see Extending Metadata Using Attributes.
| Topic | Location |
|---|---|
| Developing Custom Data-Bound Web Server Controls for ASP.NET 1.1 | Authoring ASP.NET Controls |
| Walkthrough: Developing and Using a Custom Server Control | Authoring ASP.NET Controls |
| Developing Custom Data-Bound Web Server Controls for ASP.NET 2.0 | Authoring ASP.NET Controls |
| Walkthrough: Creating a Custom Data-Bound ASP.NET Web Control for ASP.NET 2.0 | Authoring ASP.NET Controls |
| Walkthrough: Creating a Custom Data-Bound ASP.NET Web Control for ASP.NET 1.1 | Authoring ASP.NET Controls |
| Walkthrough: Developing and Using a Custom Server Control | Authoring ASP.NET Controls |
| Developing Custom Data-Bound Web Server Controls for ASP.NET 1.1 | Authoring ASP.NET Controls |
| Developing Custom Data-Bound Web Server Controls for ASP.NET 2.0 | Authoring ASP.NET Controls |
| Walkthrough: Creating a Custom Data-Bound ASP.NET Web Control for ASP.NET 2.0 | Authoring ASP.NET Controls |
| Walkthrough: Creating a Custom Data-Bound ASP.NET Web Control for ASP.NET 1.1 | Authoring ASP.NET Controls |
The following example creates the MyImage property. The property has two attributes, a DescriptionAttribute and a CategoryAttribute.
The next example gets the description of MyImage. First the code gets a PropertyDescriptorCollection with all the properties for the object. Next it indexes into the PropertyDescriptorCollection to get MyImage. Then it returns the attributes for this property and saves them in the attributes variable.
The example then prints the description by retrieving DescriptionAttribute from the AttributeCollection, and writing it to the console screen.
' Gets the attributes for the property. Dim attributes As AttributeCollection = _ TypeDescriptor.GetProperties(Me)("MyImage").Attributes ' Prints the description by retrieving the DescriptionAttribute ' from the AttributeCollection. Dim myAttribute As DescriptionAttribute = _ CType(attributes(GetType(DescriptionAttribute)), DescriptionAttribute) Console.WriteLine(myAttribute.Description)
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
