PropertyDescriptorCollection.Find(String, Boolean) Método
Definição
Retorna o PropertyDescriptor com o nome especificado, usando um booliano para indicar se você deseja ignorar a diferenciação de maiúsculas e minúsculas.Returns the PropertyDescriptor with the specified name, using a Boolean to indicate whether to ignore case.
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
Parâmetros
- name
- String
O nome do PropertyDescriptor a ser retornado da coleção.The name of the PropertyDescriptor to return from the collection.
- ignoreCase
- Boolean
true se você quiser ignorar a diferenciação de maiúsculas e minúsculas no nome da propriedade, caso contrário, false.true if you want to ignore the case of the property name; otherwise, false.
Retornos
Um PropertyDescriptor com o nome especificado ou null se a propriedade não existir.A PropertyDescriptor with the specified name, or null if the property does not exist.
Exemplos
O exemplo de código a seguir localiza um específico PropertyDescriptor .The following code example finds a specific PropertyDescriptor. Ele imprime o tipo de componente para isso PropertyDescriptor em uma caixa de texto.It prints the type of component for this PropertyDescriptor in a text box. Ele requer que button1 e textBox1 tenha sido instanciado em um formulário.It requires that button1 and textBox1 have been instantiated on a form.
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