PropertyDescriptor Class
Provides an abstraction of a property on a class.
System.ComponentModel::MemberDescriptor
System.ComponentModel::PropertyDescriptor
System.ComponentModel::DependencyPropertyDescriptor
System.ComponentModel::TypeConverter::SimplePropertyDescriptor
Assembly: System (in System.dll)
The PropertyDescriptor type exposes the following members.
| Name | Description | |
|---|---|---|
![]() ![]() | PropertyDescriptor(MemberDescriptor) | Initializes a new instance of the PropertyDescriptor class with the name and attributes in the specified MemberDescriptor. |
![]() ![]() | PropertyDescriptor(MemberDescriptor, array<Attribute>) | Initializes a new instance of the PropertyDescriptor class with the name in the specified MemberDescriptor and the attributes in both the MemberDescriptor and the Attribute array. |
![]() ![]() | PropertyDescriptor(String, array<Attribute>) | Initializes a new instance of the PropertyDescriptor class with the specified name and attributes. |
| Name | Description | |
|---|---|---|
![]() ![]() | AttributeArray | Gets or sets an array of attributes. (Inherited from MemberDescriptor.) |
![]() | Attributes | Gets the collection of attributes for this member. (Inherited from MemberDescriptor.) |
![]() | Category | Gets the name of the category to which the member belongs, as specified in the CategoryAttribute. (Inherited from MemberDescriptor.) |
![]() ![]() | ComponentType | When overridden in a derived class, gets the type of the component this property is bound to. |
![]() | Converter | Gets the type converter for this property. |
![]() | Description | Gets the description of the member, as specified in the DescriptionAttribute. (Inherited from MemberDescriptor.) |
![]() | DesignTimeOnly | Gets whether this member should be set only at design time, as specified in the DesignOnlyAttribute. (Inherited from MemberDescriptor.) |
![]() ![]() | DisplayName | Gets the name that can be displayed in a window, such as a Properties window. (Inherited from MemberDescriptor.) |
![]() | IsBrowsable | Gets a value indicating whether the member is browsable, as specified in the BrowsableAttribute. (Inherited from MemberDescriptor.) |
![]() | IsLocalizable | Gets a value indicating whether this property should be localized, as specified in the LocalizableAttribute. |
![]() ![]() | IsReadOnly | When overridden in a derived class, gets a value indicating whether this property is read-only. |
![]() ![]() | Name | Gets the name of the member. (Inherited from MemberDescriptor.) |
![]() ![]() | NameHashCode | Gets the hash code for the name of the member, as specified in GetHashCode. (Inherited from MemberDescriptor.) |
![]() ![]() | PropertyType | When overridden in a derived class, gets the type of the property. |
![]() | SerializationVisibility | Gets a value indicating whether this property should be serialized, as specified in the DesignerSerializationVisibilityAttribute. |
![]() ![]() | SupportsChangeEvents | Gets a value indicating whether value change notifications for this property may originate from outside the property descriptor. |
| Name | Description | |
|---|---|---|
![]() ![]() | AddValueChanged | Enables other objects to be notified when this property changes. |
![]() ![]() | CanResetValue | When overridden in a derived class, returns whether resetting an object changes its value. |
![]() ![]() | CreateAttributeCollection | Creates a collection of attributes using the array of attributes passed to the constructor. (Inherited from MemberDescriptor.) |
![]() | CreateInstance | Creates an instance of the specified type. |
![]() ![]() | Equals | Compares this to another object to see if they are equivalent. (Overrides MemberDescriptor::Equals(Object).) In XNA Framework 3.0, this member is inherited from Object::Equals(Object). |
![]() ![]() | FillAttributes | Adds the attributes of the PropertyDescriptor to the specified list of attributes in the parent class. (Overrides MemberDescriptor::FillAttributes(IList).) In XNA Framework 3.0, this member is inherited from MemberDescriptor::FillAttributes(IList). |
![]() ![]() | Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) |
![]() | GetChildProperties() | Returns the default PropertyDescriptorCollection. |
![]() | GetChildProperties(array<Attribute>) | Returns a PropertyDescriptorCollection using a specified array of attributes as a filter. |
![]() | GetChildProperties(Object) | Returns a PropertyDescriptorCollection for a given object. |
![]() | GetChildProperties(Object, array<Attribute>) | Returns a PropertyDescriptorCollection for a given object using a specified array of attributes as a filter. |
![]() | GetEditor | Gets an editor of the specified type. |
![]() ![]() | GetHashCode | Returns the hash code for this object. (Overrides MemberDescriptor::GetHashCode().) In XNA Framework, this member is overridden by GetHashCode(). |
![]() | GetInvocationTarget | This method returns the object that should be used during invocation of members. (Overrides MemberDescriptor::GetInvocationTarget(Type, Object).) |
![]() ![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | GetTypeFromName | Returns a type using its name. |
![]() ![]() | GetValue | When overridden in a derived class, gets the current value of the property on a component. |
![]() ![]() | GetValueChangedHandler | Retrieves the current set of ValueChanged event handlers for a specific component |
![]() ![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() ![]() | OnValueChanged | Raises the ValueChanged event that you implemented. |
![]() ![]() | RemoveValueChanged | Enables other objects to be notified when this property changes. |
![]() ![]() | ResetValue | When overridden in a derived class, resets the value for this property of the component to the default value. |
![]() ![]() | SetValue | When overridden in a derived class, sets the value of the component to a different value. |
![]() ![]() | ShouldSerializeValue | When overridden in a derived class, determines a value indicating whether the value of this property needs to be persisted. |
![]() ![]() | ToString | Returns a string that represents the current object. (Inherited from Object.) |
A description of a property consists of a name, its attributes, the component class that the property is associated with, and the type of the property.
PropertyDescriptor provides the following properties and methods:
Converter contains the TypeConverter for this property.
IsLocalizable indicates whether this property should be localized.
GetEditor returns an editor of the specified type.
PropertyDescriptor also provides the following abstract properties and methods:
ComponentType contains the type of component this property is bound to.
IsReadOnly indicates whether this property is read-only.
PropertyType gets the type of the property.
CanResetValue indicates whether resetting the component changes the value of the component.
GetValue returns the current value of the property on a component.
ResetValue resets the value for this property of the component.
SetValue sets the value of the component to a different value.
ShouldSerializeValue indicates whether the value of this property needs to be persisted.
Typically, the abstract members are implemented through reflection. For more information about reflection, see the topics in Reflection in the .NET Framework.
Note |
|---|
The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: SharedState. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes. |
The following code example is built upon the example in the PropertyDescriptorCollection class. It prints the information (category, description, display name) of the text of a button in a text box. It assumes that button1 and textbox1 have been instantiated on a form.
// Creates a new collection and assign it the properties for button1. PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 ); // Sets an PropertyDescriptor to the specific property. System::ComponentModel::PropertyDescriptor^ myProperty = properties->Find( "Text", false ); // Prints the property and the property description. textBox1->Text = String::Concat( myProperty->DisplayName, "\n" ); textBox1->Text = String::Concat( textBox1->Text, myProperty->Description, "\n" ); textBox1->Text = String::Concat( textBox1->Text, myProperty->Category, "\n" );
The following code example shows how to implement a custom property descriptor that provides a read-only wrapper around a property. The SerializeReadOnlyPropertyDescriptor is used in a custom designer to provide a read-only property descriptor for the control's Size property.
The following code examples show how to use the The SerializeReadOnlyPropertyDescriptor in a custom designer.
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.
