PropertyDescriptorCollection Class
 

Represents a collection of PropertyDescriptor objects.

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)

SystemObject
  System.ComponentModelPropertyDescriptorCollection

[HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true)]
public class PropertyDescriptorCollection : ICollection, IEnumerable, 
	IList, IDictionary
[HostProtectionAttribute(SecurityAction::LinkDemand, Synchronization = true)]
public ref class PropertyDescriptorCollection : ICollection, 
	IEnumerable, IList, IDictionary
[<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization = true)>]
type PropertyDescriptorCollection = 
    class
        interface ICollection
        interface IEnumerable
        interface IList
        interface IDictionary
    end
<HostProtectionAttribute(SecurityAction.LinkDemand, Synchronization := True)>
Public Class PropertyDescriptorCollection
	Implements ICollection, IEnumerable, IList, IDictionary
NameDescription
System_CAPS_pubmethod PropertyDescriptorCollection

Initializes a new instance of the PropertyDescriptorCollection class.

System_CAPS_pubmethod PropertyDescriptorCollection

Initializes a new instance of the PropertyDescriptorCollection class, which is optionally read-only.

NameDescription
System_CAPS_pubproperty

Gets the number of property descriptors in the collection.

System_CAPS_pubproperty

Gets or sets the PropertyDescriptor at the specified index number.

System_CAPS_pubproperty

Gets or sets the PropertyDescriptor with the specified name.

NameDescription
System_CAPS_pubmethod Add

Adds the specified PropertyDescriptor to the collection.

System_CAPS_pubmethod Clear

Removes all PropertyDescriptor objects from the collection.

System_CAPS_pubmethod Contains

Returns whether the collection contains the given PropertyDescriptor.

System_CAPS_pubmethod CopyTo

Copies the entire collection to an array, starting at the specified index number.

System_CAPS_pubmethod Equals

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethod Finalize

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethod Find

Returns the PropertyDescriptor with the specified name, using a Boolean to indicate whether to ignore case.

System_CAPS_pubmethod GetEnumerator

Returns an enumerator for this class.

System_CAPS_pubmethod GetHashCode

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethod GetType

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethod IndexOf

Returns the index of the given PropertyDescriptor.

System_CAPS_pubmethod Insert

Adds the PropertyDescriptor to the collection at the specified index number.

System_CAPS_protmethod InternalSort

Sorts the members of this collection, using the specified IComparer.

System_CAPS_protmethod InternalSort

Sorts the members of this collection. The specified order is applied first, followed by the default sort for this collection, which is usually alphabetical.

System_CAPS_protmethod MemberwiseClone

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethod Remove

Removes the specified PropertyDescriptor from the collection.

System_CAPS_pubmethod RemoveAt

Removes the PropertyDescriptor at the specified index from the collection.

System_CAPS_pubmethod Sort

Sorts the members of this collection, using the default sort for this collection, which is usually alphabetical.

System_CAPS_pubmethod Sort

Sorts the members of this collection, using the specified IComparer.

System_CAPS_pubmethod Sort

Sorts the members of this collection. The specified order is applied first, followed by the default sort for this collection, which is usually alphabetical.

System_CAPS_pubmethod Sort

Sorts the members of this collection. The specified order is applied first, followed by the sort using the specified IComparer.

System_CAPS_pubmethod ToString

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubfield System_CAPS_static Empty

Specifies an empty collection that you can use instead of creating a new one with no items. This static field is read-only.

NameDescription
System_CAPS_pubinterface System_CAPS_privmethod IDictionaryAdd

Adds an element with the provided key and value to the IDictionary.

System_CAPS_pubinterface System_CAPS_privmethod IDictionaryClear

Removes all elements from the IDictionary.

System_CAPS_pubinterface System_CAPS_privmethod IDictionaryContains

Determines whether the IDictionary contains an element with the specified key.

System_CAPS_pubinterface System_CAPS_privmethod IDictionaryGetEnumerator

Returns an enumerator for this class.

System_CAPS_pubinterface System_CAPS_privmethod IDictionaryRemove

Removes the element with the specified key from the IDictionary.

System_CAPS_pubinterface System_CAPS_privmethod IEnumerableGetEnumerator

Returns an IEnumerator for the IDictionary.

System_CAPS_pubinterface System_CAPS_privmethod IListAdd

Adds an item to the IList.

System_CAPS_pubinterface System_CAPS_privmethod IListClear

Removes all items from the collection.

System_CAPS_pubinterface System_CAPS_privmethod IListContains

Determines whether the collection contains a specific value.

System_CAPS_pubinterface System_CAPS_privmethod IListIndexOf

Determines the index of a specified item in the collection.

System_CAPS_pubinterface System_CAPS_privmethod IListInsert

Inserts an item into the collection at a specified index.

System_CAPS_pubinterface System_CAPS_privmethod IListRemove

Removes the first occurrence of a specified value from the collection.

System_CAPS_pubinterface System_CAPS_privmethod IListRemoveAt

Removes the item at the specified index.

System_CAPS_pubinterface System_CAPS_privproperty

Gets the number of elements contained in the collection.

System_CAPS_pubinterface System_CAPS_privproperty

Gets a value indicating whether access to the collection is synchronized (thread safe).

System_CAPS_pubinterface System_CAPS_privproperty

Gets an object that can be used to synchronize access to the collection.

System_CAPS_pubinterface System_CAPS_privproperty

Gets a value indicating whether the IDictionary has a fixed size.

System_CAPS_pubinterface System_CAPS_privproperty

Gets a value indicating whether the IDictionary is read-only.

System_CAPS_pubinterface System_CAPS_privproperty

Gets or sets the element with the specified key.

System_CAPS_pubinterface System_CAPS_privproperty

Gets an ICollection containing the keys of the IDictionary.

System_CAPS_pubinterface System_CAPS_privproperty

Gets an ICollection containing the values in the IDictionary.

System_CAPS_pubinterface System_CAPS_privproperty

Gets a value indicating whether the collection has a fixed size.

System_CAPS_pubinterface System_CAPS_privproperty

Gets a value indicating whether the collection is read-only.

System_CAPS_pubinterface System_CAPS_privproperty

Gets or sets an item from the collection at a specified index.

NameDescription
System_CAPS_pubmethod AsParallel

Overloaded. Enables parallelization of a query.(Defined by ParallelEnumerable.)

System_CAPS_pubmethod AsQueryable

Overloaded. Converts an IEnumerable to an IQueryable.(Defined by Queryable.)

System_CAPS_pubmethod Cast

Casts the elements of an IEnumerable to the specified type.(Defined by Enumerable.)

System_CAPS_pubmethod OfType

Filters the elements of an IEnumerable based on a specified type.(Defined by Enumerable.)

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 property to determine the number of elements in the collection. Use the 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.

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

PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);
Dim properties As PropertyDescriptorCollection = 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 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 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.
      for each ( PropertyDescriptor^ myProperty in properties )
      {
         textBox1->Text = String::Concat( textBox1->Text, myProperty->Name, "\n" );
      }
   }
.NET Framework
Available since 1.1

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top