PropertyDescriptorCollection.Find(String, Boolean) Método

Definição

Devolve o PropertyDescriptor com o nome especificado, usando um Booleano para indicar se deve ignorar o caso.

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

Parâmetros

name
String

O nome do PropertyDescriptor a regressar da coleção.

ignoreCase
Boolean

true Se quiseres ignorar o caso do nome da propriedade; caso contrário, false.

Devoluções

A PropertyDescriptor com o nome especificado, ou null se a propriedade não existir.

Exemplos

O seguinte exemplo de código encontra um .PropertyDescriptor Imprime o tipo de componente para isto PropertyDescriptor numa caixa de texto. Requer isso button1 e textBox1 ter sido instanciado num formulário.

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

Aplica-se a

Ver também