Windows Dev Center

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 (String)

Gets or sets the PropertyDescriptor with the specified name.

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

public virtual PropertyDescriptor this[
	string name
] { get; }

Parameters

name
Type: System.String

The name of the PropertyDescriptor to get from the collection.

Property Value

Type: System.ComponentModel.PropertyDescriptor
The PropertyDescriptor with the specified name, or null if the property does not exist.

The Item property is case-sensitive when searching for names. That is, the names "Pname" and "pname" are considered to be two different properties.

The following code example uses the Item property to print the type of component for the PropertyDescriptor specified by the index. It requires that button1 and textBox1 have been instantiated on a form.

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

    // Sets a PropertyDescriptor to the specific property.
    PropertyDescriptor myProperty = properties["Opacity"];

    // Prints the display name for the property.
    textBox1.Text = myProperty.DisplayName;
 }

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0
Show:
© 2015 Microsoft