PropertyDescriptorCollection.Find(String, Boolean) Metoda

Definice

Vrátí hodnotu se PropertyDescriptor zadaným názvem, pomocí logické hodnoty označující, zda se mají ignorovat malá a velká písmena.

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

Parametry

name
String

Název objektu, který PropertyDescriptor se má vrátit z kolekce.

ignoreCase
Boolean

trueChcete-li ignorovat velká písmena názvu vlastnosti; v opačném případě . false

Návraty

A PropertyDescriptor se zadaným názvem nebo null pokud vlastnost neexistuje.

Příklady

Následující příklad kódu najde konkrétní PropertyDescriptor. Vytiskne typ komponenty pro tento PropertyDescriptor typ v textovém poli. Vyžaduje, aby button1 ve formuláři byla vytvořena instance a textBox1 .

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.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

Platí pro

Viz také