Export (0) Print
Expand All

PropertyDescriptorCollection.Item Property (Int32)

Gets or sets the PropertyDescriptor at the specified index number.

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

public virtual PropertyDescriptor this[
	int index
] { get; }


Type: System.Int32

The zero-based index of the PropertyDescriptor to get or set.

Property Value

Type: System.ComponentModel.PropertyDescriptor
The PropertyDescriptor with the specified index number.


The index parameter is not a valid index for Item.

The index number is zero-based. Therefore, you must subtract 1 from the numerical position of a particular PropertyDescriptor to access that PropertyDescriptor. For example, to get the third PropertyDescriptor, you need to specify myColl[2].

The following code example uses the Item property to print the name of the PropertyDescriptor specified by the index number in a text box. Because the index number is zero-based, this example prints the name of the second PropertyDescriptor. It requires that button1 has been instantiated on a form.

private void PrintIndexItem() {
    // Creates a new collection and assigns it the properties for button1.
    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);

    // Prints the second property's name.
    textBox1.Text = properties[1].ToString();

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft