Skip to main content
.NET Framework Class Library
PropertyDescriptorCollection Class

Represents a collection of PropertyDescriptor objects.

Inheritance Hierarchy
SystemObject
  System.ComponentModelPropertyDescriptorCollection

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)
Syntax
<[%$TOPIC/6x5wesx5_en-us_VS_110_3_0_0_0_0%]([%$TOPIC/6x5wesx5_en-us_VS_110_3_0_0_0_1%].LinkDemand, Synchronization := True)> _
Public Class PropertyDescriptorCollection _
	Implements [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_0_0_2%], [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_0_0_3%], [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_0_0_4%], [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_0_0_5%]
[[%$TOPIC/6x5wesx5_en-us_VS_110_3_0_1_0_0%]([%$TOPIC/6x5wesx5_en-us_VS_110_3_0_1_0_1%].LinkDemand, Synchronization = true)]
public class PropertyDescriptorCollection : [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_1_0_2%], 
	[%$TOPIC/6x5wesx5_en-us_VS_110_3_0_1_0_3%], [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_1_0_4%], [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_1_0_5%]
[[%$TOPIC/6x5wesx5_en-us_VS_110_3_0_2_0_0%]([%$TOPIC/6x5wesx5_en-us_VS_110_3_0_2_0_1%]::LinkDemand, Synchronization = true)]
public ref class PropertyDescriptorCollection : [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_2_0_2%], 
	[%$TOPIC/6x5wesx5_en-us_VS_110_3_0_2_0_3%], [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_2_0_4%], [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_2_0_5%]
[<[%$TOPIC/6x5wesx5_en-us_VS_110_3_0_3_0_0%]([%$TOPIC/6x5wesx5_en-us_VS_110_3_0_3_0_1%].LinkDemand, Synchronization = true)>]
type PropertyDescriptorCollection =  
    class 
        interface [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_3_0_2%] 
        interface [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_3_0_3%] 
        interface [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_3_0_4%] 
        interface [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_3_0_5%] 
    end
public class PropertyDescriptorCollection implements [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_4_0_0%], [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_4_0_1%], [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_4_0_2%], [%$TOPIC/6x5wesx5_en-us_VS_110_3_0_4_0_3%]

The PropertyDescriptorCollection type exposes the following members.

Constructors
  NameDescription
Public method Supported by the XNA Framework PropertyDescriptorCollection(PropertyDescriptor)Initializes a new instance of the PropertyDescriptorCollection class.
Public method PropertyDescriptorCollection(PropertyDescriptor, Boolean)Initializes a new instance of the PropertyDescriptorCollection class, which is optionally read-only.
Top
Properties
  NameDescription
Public property Supported by the XNA Framework CountGets the number of property descriptors in the collection.
Public property Supported by the XNA Framework ItemInt32Gets or sets the PropertyDescriptor at the specified index number.
Public property Supported by the XNA Framework ItemStringGets or sets the PropertyDescriptor with the specified name.
Top
Methods
  NameDescription
Public method Supported by the XNA Framework AddAdds the specified PropertyDescriptor to the collection.
Public method Supported by the XNA Framework ClearRemoves all PropertyDescriptor objects from the collection.
Public method Supported by the XNA Framework ContainsReturns whether the collection contains the given PropertyDescriptor.
Public method Supported by the XNA Framework CopyToCopies the entire collection to an array, starting at the specified index number.
Public method Supported by the XNA Framework Equals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected method Supported by the XNA Framework FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method Supported by the XNA Framework FindReturns the PropertyDescriptor with the specified name, using a Boolean to indicate whether to ignore case.
Public method Supported by the XNA Framework GetEnumeratorReturns an enumerator for this class.
Public method Supported by the XNA Framework GetHashCodeServes as the default hash function. (Inherited from Object.)
Public method Supported by the XNA Framework GetTypeGets the Type of the current instance. (Inherited from Object.)
Public method Supported by the XNA Framework IndexOfReturns the index of the given PropertyDescriptor.
Public method Supported by the XNA Framework InsertAdds the PropertyDescriptor to the collection at the specified index number.
Protected method InternalSort(IComparer)Sorts the members of this collection, using the specified IComparer.
Protected method InternalSort(String)Sorts the members of this collection. The specified order is applied first, followed by the default sort for this collection, which is usually alphabetical.
Protected method Supported by the XNA Framework MemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public method Supported by the XNA Framework RemoveRemoves the specified PropertyDescriptor from the collection.
Public method Supported by the XNA Framework RemoveAtRemoves the PropertyDescriptor at the specified index from the collection.
Public method SortSorts the members of this collection, using the default sort for this collection, which is usually alphabetical.
Public method Sort(IComparer)Sorts the members of this collection, using the specified IComparer.
Public method Sort(String)Sorts the members of this collection. The specified order is applied first, followed by the default sort for this collection, which is usually alphabetical.
Public method Sort(String, IComparer)Sorts the members of this collection. The specified order is applied first, followed by the sort using the specified IComparer.
Public method Supported by the XNA Framework ToStringReturns a string that represents the current object. (Inherited from Object.)
Top
Extension Methods
  NameDescription
Public Extension Method AsParallelEnables parallelization of a query. (Defined by ParallelEnumerable.)
Public Extension Method AsQueryableConverts an IEnumerable to an IQueryable. (Defined by Queryable.)
Public Extension Method Supported by the XNA Framework CastTResultCasts the elements of an IEnumerable to the specified type. (Defined by Enumerable.)
Public Extension Method Supported by the XNA Framework OfTypeTResultFilters the elements of an IEnumerable based on a specified type. (Defined by Enumerable.)
Top
Fields
  NameDescription
Public field Static member Supported by the XNA Framework EmptySpecifies an empty collection that you can use instead of creating a new one with no items. This static field is read-only.
Top
Explicit Interface Implementations
  NameDescription
Explicit interface implemetation Private property Supported by the XNA Framework ICollectionCountGets the number of elements contained in the collection.
Explicit interface implemetation Private property Supported by the XNA Framework ICollectionIsSynchronizedGets a value indicating whether access to the collection is synchronized (thread safe).
Explicit interface implemetation Private property Supported by the XNA Framework ICollectionSyncRootGets an object that can be used to synchronize access to the collection.
Explicit interface implemetation Private method Supported by the XNA Framework IDictionaryAddAdds an element with the provided key and value to the IDictionary.
Explicit interface implemetation Private method Supported by the XNA Framework IDictionaryClearRemoves all elements from the IDictionary.
Explicit interface implemetation Private method Supported by the XNA Framework IDictionaryContainsDetermines whether the IDictionary contains an element with the specified key.
Explicit interface implemetation Private method Supported by the XNA Framework IDictionaryGetEnumeratorReturns an enumerator for this class.
Explicit interface implemetation Private property Supported by the XNA Framework IDictionaryIsFixedSizeGets a value indicating whether the IDictionary has a fixed size.
Explicit interface implemetation Private property Supported by the XNA Framework IDictionaryIsReadOnlyGets a value indicating whether the IDictionary is read-only.
Explicit interface implemetation Private property Supported by the XNA Framework IDictionaryItemGets or sets the element with the specified key.
Explicit interface implemetation Private property Supported by the XNA Framework IDictionaryKeysGets an ICollection containing the keys of the IDictionary.
Explicit interface implemetation Private method Supported by the XNA Framework IDictionaryRemoveRemoves the element with the specified key from the IDictionary.
Explicit interface implemetation Private property Supported by the XNA Framework IDictionaryValuesGets an ICollection containing the values in the IDictionary.
Explicit interface implemetation Private method Supported by the XNA Framework IEnumerableGetEnumeratorReturns an IEnumerator for the IDictionary.
Explicit interface implemetation Private method Supported by the XNA Framework IListAddAdds an item to the IList.
Explicit interface implemetation Private method Supported by the XNA Framework IListClearRemoves all items from the collection.
Explicit interface implemetation Private method Supported by the XNA Framework IListContainsDetermines whether the collection contains a specific value.
Explicit interface implemetation Private method Supported by the XNA Framework IListIndexOfDetermines the index of a specified item in the collection.
Explicit interface implemetation Private method Supported by the XNA Framework IListInsertInserts an item into the collection at a specified index.
Explicit interface implemetation Private property Supported by the XNA Framework IListIsFixedSizeGets a value indicating whether the collection has a fixed size.
Explicit interface implemetation Private property Supported by the XNA Framework IListIsReadOnlyGets a value indicating whether the collection is read-only.
Explicit interface implemetation Private property Supported by the XNA Framework IListItemGets or sets an item from the collection at a specified index.
Explicit interface implemetation Private method Supported by the XNA Framework IListRemoveRemoves the first occurrence of a specified value from the collection.
Explicit interface implemetation Private method Supported by the XNA Framework IListRemoveAtRemoves the item at the specified index.
Top
Remarks

PropertyDescriptorCollection is read-only; it does not implement methods that add or remove properties. You must inherit from this class to implement these methods.

Using the properties available in the PropertyDescriptorCollection class, you can query the collection about its contents. Use the Count property to determine the number of elements in the collection. Use the Item property to get a specific property by index number or by name.

In addition to properties, you can use the Find method to get a description of the property with the specified name from the collection.

NoteNote

The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: Synchronization. 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.

Examples

The following code example creates a new PropertyDescriptorCollection using the properties on button1. It requires that button1 has been instantiated on a form.

Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(button1)
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);
PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );

The next example prints all the properties on a button in a text box. It requires that button1 and textBox1 have been instantiated on a form.

Private Sub MyPropertyCollection()
    ' Creates a new collection and assign it the properties for button1. 
    Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(button1)

    ' Displays each property in the collection in a text box. 
    Dim myProperty As PropertyDescriptor
    For Each myProperty In  properties
        textBox1.Text &= myProperty.Name & ControlChars.Cr
    Next myProperty
End Sub 'MyPropertyCollection 
private void MyPropertyCollection() {
    // Creates a new collection and assign it the properties for button1.
    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);

    // Displays each property in the collection in a text box. 
    foreach (PropertyDescriptor myProperty in properties)
       textBox1.Text += myProperty.Name + '\n';
 }
private:
   void MyPropertyCollection()
   {
      // Creates a new collection and assign it the properties for button1.
      PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );

      // Displays each property in the collection in a text box. 
      for each ( PropertyDescriptor^ myProperty in properties )
      {
         textBox1->Text = String::Concat( textBox1->Text, myProperty->Name, "\n" );
      }
   }
Version Information

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0
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.