Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DescriptionAttribute Class

Specifies a description for a property or event.

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

         Derived classes

[Visual Basic]
Public Class DescriptionAttribute
   Inherits Attribute
public class DescriptionAttribute : Attribute
public __gc class DescriptionAttribute : public Attribute
class DescriptionAttribute 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.


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 Attributes Overview and Extending Metadata Using Attributes.


[Visual Basic, C#, C++] The following example creates the MyImage property. The property has two attributes, a DescriptionAttribute and a CategoryAttribute.

[Visual Basic] 
<Description("The image associated with the control"), _
    Category("Appearance")> _
Public Property MyImage() As Image
        ' Insert code here.
        Return image1
    End Get
        ' Insert code here.
    End Set 
End Property

[Description("The image associated with the control"),Category("Appearance")] 
 public Image MyImage {
    get {
       // Insert code here.
       return image1;
    set {
       // Insert code here.

    [Description(S"The image associated with the control"),Category(S"Appearance")] 
     __property Image* get_MyImage() {
           // Insert code here.
           return image1;
     __property void set_MyImage( Image* value ) {
           // Insert code here.

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

[Visual Basic, C#, C++] The example then prints the description by retrieving DescriptionAttribute from the AttributeCollection, and writing it to the console screen.

[Visual Basic] 
' Gets the attributes for the property.
Dim attributes As AttributeCollection = _

' Prints the description by retrieving the DescriptionAttribute
' from the AttributeCollection. 
Dim myAttribute As DescriptionAttribute = _
    CType(attributes(GetType(DescriptionAttribute)), DescriptionAttribute)

// Gets the attributes for the property.
 AttributeCollection attributes = 
 /* Prints the description by retrieving the DescriptionAttribute 
  * from the AttributeCollection. */
 DescriptionAttribute myAttribute = 

// Gets the attributes for the property.
 AttributeCollection* attributes = 
 /* Prints the description by retrieving the DescriptionAttribute 
  * from the AttributeCollection. */
 DescriptionAttribute* myAttribute = 

[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

DescriptionAttribute Members | System.ComponentModel Namespace | Attribute | PropertyDescriptor | EventDescriptor

© 2018 Microsoft