PropertyDescriptorCollection.Find(String, Boolean) Metodo

Definizione

Restituisce l'oggetto PropertyDescriptor con il nome specificato, utilizzando un valore Boolean per indicare se ignorare la distinzione fra maiuscole e minuscole.

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

Parametri

name
String

Nome dell'oggetto PropertyDescriptor da restituire dall'insieme.

ignoreCase
Boolean

true se si desidera ignorare la distinzione fra maiuscole e minuscole del nome della proprietà, in caso contrario false.

Restituisce

PropertyDescriptor

Oggetto PropertyDescriptor con il nome specificato oppure null se la proprietà non esiste.

Esempio

Nell'esempio di codice seguente viene trovato un oggetto specifico PropertyDescriptor. Stampa il tipo di componente in PropertyDescriptor una casella di testo. Richiede che button1 e textBox1 sia stata creata un'istanza in un modulo.

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

Si applica a

Vedi anche