PropertyDescriptorCollection.Find(String, Boolean) Metoda

Definicja

Zwraca element PropertyDescriptor z określoną nazwą przy użyciu wartości logicznej, aby wskazać, czy ignorować wielkość liter.

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

Nazwa elementu PropertyDescriptor do zwrócenia z kolekcji.

ignoreCase
Boolean

true jeśli chcesz zignorować wielkość liter nazwy właściwości; w przeciwnym razie , false.

Zwraca

Element PropertyDescriptor o określonej nazwie lub null jeśli właściwość nie istnieje.

Przykłady

Poniższy przykład kodu znajduje określony PropertyDescriptorelement . Wyświetla typ składnika dla tego PropertyDescriptor elementu w polu tekstowym. Wymaga to utworzenia button1textBox1 wystąpienia i utworzenia wystąpienia w formularzu.

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

Dotyczy

Zobacz też