PropertyDescriptorCollection.Find(String, Boolean) Methode

Definitie

Retourneert de PropertyDescriptor met de opgegeven naam, waarbij een Booleaanse waarde wordt gebruikt om aan te geven of hoofdletters moeten worden genegeerd.

public:
 virtual System::ComponentModel::PropertyDescriptor ^ Find(System::String ^ name, bool ignoreCase);
public virtual System.ComponentModel.PropertyDescriptor? Find(string name, bool ignoreCase);
public virtual System.ComponentModel.PropertyDescriptor Find(string name, bool ignoreCase);
abstract member Find : string * bool -> System.ComponentModel.PropertyDescriptor
override this.Find : string * bool -> System.ComponentModel.PropertyDescriptor
Public Overridable Function Find (name As String, ignoreCase As Boolean) As PropertyDescriptor

Parameters

name
String

De naam van de PropertyDescriptor te retourneren verzameling.

ignoreCase
Boolean

true als u het hoofdlettergebruik van de eigenschapsnaam wilt negeren; anders, false.

Retouren

Een PropertyDescriptor met de opgegeven naam of null als de eigenschap niet bestaat.

Voorbeelden

In het volgende codevoorbeeld wordt een specifieke PropertyDescriptor. Hiermee wordt het type onderdeel voor dit PropertyDescriptor in een tekstvak afgedrukt. Hiervoor moet button1 een formulier worden geïnstantieerd en textBox1 geïnstantieerd.

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;
   }
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 Sub FindProperty()
    ' Creates a new collection and assign it the properties for button1.
    Dim properties As PropertyDescriptorCollection = _
       TypeDescriptor.GetProperties(button1)
       
    ' Sets a PropertyDescriptor to the specific property.
    Dim myProperty As PropertyDescriptor = properties.Find("Opacity", False)
       
    ' Prints the property and the property description.
    textBox1.Text = myProperty.DisplayName & _
       Microsoft.VisualBasic.ControlChars.Cr & myProperty.Description
End Sub

Van toepassing op

Zie ook