PropertyDescriptorCollection.Find(String, Boolean) Méthode

Définition

Retourne le PropertyDescriptor nom spécifié à l’aide d’une valeur booléenne pour indiquer s’il faut ignorer la casse.

public:
 virtual System::ComponentModel::PropertyDescriptor ^ Find(System::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

Paramètres

name
String

Nom du PropertyDescriptor retour de la collection.

ignoreCase
Boolean

true si vous souhaitez ignorer le cas du nom de la propriété ; sinon, false.

Retours

Avec PropertyDescriptor le nom spécifié ou null si la propriété n’existe pas.

Exemples

L’exemple de code suivant recherche un élément spécifique PropertyDescriptor. Il imprime le type de composant pour cela PropertyDescriptor dans une zone de texte. Elle exige qu’elle button1 ait textBox1 été instanciée sur un formulaire.

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

S’applique à

Voir aussi