PropertyDescriptorCollection.Find(String, Boolean) Method

Definition

Returns the PropertyDescriptor with the specified name, using a Boolean to indicate whether to ignore case.

C#
public virtual System.ComponentModel.PropertyDescriptor? Find(string name, bool ignoreCase);
C#
public virtual System.ComponentModel.PropertyDescriptor Find(string name, bool ignoreCase);

Parameters

name
String

The name of the PropertyDescriptor to return from the collection.

ignoreCase
Boolean

true if you want to ignore the case of the property name; otherwise, false.

Returns

A PropertyDescriptor with the specified name, or null if the property does not exist.

Examples

The following code example finds a specific PropertyDescriptor. It prints the type of component for this PropertyDescriptor in a text box. It requires that button1 and textBox1 have been instantiated on a form.

C#
private void FindProperty() {
   // Creates a new collection and assign it the properties for button1.
   PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);

   // Sets a PropertyDescriptor to the specific property.
   PropertyDescriptor myProperty = properties.Find("Opacity", false);

   // Prints the property and the property description.
   textBox1.Text = myProperty.DisplayName + '\n' + myProperty.Description;
}

Applies to

Produkt Versiounen
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0, 2.1

See also