Windows apps
Collapse the table of content
Expand the table of content
Information
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.

PropertyDescriptorCollection::Item Property (Int32)

 

Gets or sets the PropertyDescriptor at the specified index number.

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

public:
property PropertyDescriptor^ default[
	int index
] {
	virtual PropertyDescriptor^ get(int index);
}

Parameters

index
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.

Exception Condition
IndexOutOfRangeException

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.

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
Available since 1.1
Return to top
Show:
© 2017 Microsoft