Gets the property with the specified name.
[C#] In C#, this member is the indexer for the PropertyDescriptorCollection class.
[Visual Basic] Overloads Overridable Public Default ReadOnly Property Item( _ ByVal name As String _ ) As PropertyDescriptor [C#] public PropertyDescriptor this[ string name ] {virtual get;} [C++] public: __property virtual PropertyDescriptor* get_Item( String* name ); [JScript] returnValue = PropertyDescriptorCollectionObject.Item(name); -or- returnValue = PropertyDescriptorCollectionObject(name);
[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 name, or a null reference (in Visual Basic Nothing) if the property does not exist.
Item property (PropertyDescriptorCollection indexer)is case-sensitive when searching for names. That is, if two properties exist with the names "Pname" and "pname," Item property (PropertyDescriptorCollection indexer)will find the specific property you name.
The following example uses the Item property (EventDescriptorCollection indexer) to print the type of component for the EventDescriptor specified by the index. It assumes that Button1 has been instantiated on a form.
[Visual Basic]
Private Sub PrintIndexItem2() Dim properties As PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(Button1) ' Set a PropertyDescriptor to the specific event. Dim myProperty As PropertyDescriptor myProperty = properties.Item("Opacity") ' Print the type of component for the property. TextBox1.Text = myProperty.ComponentType.ToString End Sub
PropertyDescriptorCollection Class | PropertyDescriptorCollection Members | System.ComponentModel Namespace | PropertyDescriptorCollection.Item Overload List | PropertyDescriptor | TypeDescriptor