Gets the property with the specified index number.
[C#] In C#, this member is the indexer for the PropertyDescriptorCollection class.
[Visual Basic] Overloads Overridable Public Default ReadOnly Property Item( _ ByVal index As Integer _ ) As PropertyDescriptor [C#] public PropertyDescriptor this[ int index ] {virtual get;} [C++] public: __property virtual PropertyDescriptor* get_Item( int index ); [JScript] returnValue = PropertyDescriptorCollectionObject.Item(index); -or- returnValue = PropertyDescriptorCollectionObject(index);
[JScript] In JScript, you can use the default indexed properties defined by a type, but you cannot explicitly define your own. However, specifying the expando attribute on a class automatically provides a default indexed Item property whose type is Object and whose index type is String.
The PropertyDescriptor with the specified index number.
The index number is zero-based. Therefore, you must subtract one from the numerical position of a particular PropertyDescriptor to access that PropertyDescriptor. For example, to get the third PropertyDescriptor, you need to specify Item property (PropertyDescriptorCollection indexer)(2).
The following example uses the Item property (PropertyDescriptorCollection indexer) to print the name of the PropertyDescriptor specified by the index number in a text box. Since the index number is zero-based, this example prints the name of the second PropertyDescriptor. It assumes Button1 has been instantiated on a form.
[Visual Basic]
Private Sub PrintIndexItem() Dim properties As PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(Button1) ' Print the second property's name. TextBox1.Text = properties.Item(1).Name End Sub
PropertyDescriptorCollection Class | PropertyDescriptorCollection Members | System.ComponentModel Namespace | PropertyDescriptorCollection.Item Overload List | PropertyDescriptor | TypeDescriptor