PropertyDescriptorCollection.Find(String, Boolean) 方法

定義

使用布林值 (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

傳回

具有指定名稱的 PropertyDescriptornull (如果屬性不存在)。

範例

下列程式碼範例會尋找特定的 PropertyDescriptor 。 它會在文字方塊中列印這個 PropertyDescriptor 的元件類型。 它要求 button1 已在表單上具現化 和 textBox1

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

適用於

另請參閱