PropertyDescriptorCollection.Find(String, Boolean) Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Возвращает указанное PropertyDescriptor имя, используя логическое значение, чтобы указать, следует ли игнорировать регистр.
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
Параметры
- name
- String
Имя возвращаемого PropertyDescriptor из коллекции.
- ignoreCase
- Boolean
true Значение , если вы хотите игнорировать регистр имени свойства; falseв противном случае .
Возвращаемое значение
Значение PropertyDescriptor с указанным именем или null если свойство не существует.
Примеры
В следующем примере кода находится конкретный PropertyDescriptorобъект. Он печатает тип компонента для этого PropertyDescriptor в текстовом поле. Для этого требуется button1textBox1 создать экземпляр в форме.
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