Find Method

PropertyDescriptorCollection.Find Method

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

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

public virtual PropertyDescriptor Find (
	string name,
	bool ignoreCase
)
public PropertyDescriptor Find (
	String name, 
	boolean ignoreCase
)
public function Find (
	name : String, 
	ignoreCase : boolean
) : PropertyDescriptor
Not applicable.

Parameters

name

The name of the PropertyDescriptor to return from the collection.

ignoreCase

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

Return Value

A PropertyDescriptor with the specified name, or a null reference (Nothing in Visual Basic) if the property does not exist.

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.

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;
}


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.set_Text(myProperty.get_DisplayName() + '\n' 
        + myProperty.get_Description());
} //FindProperty

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2016 Microsoft