PropertyDescriptorCollection.Find(String, Boolean) PropertyDescriptorCollection.Find(String, Boolean) PropertyDescriptorCollection.Find(String, Boolean) PropertyDescriptorCollection.Find(String, Boolean) Method

定義

使用布林值 (Boolean) 指示是否忽略大小寫,並以指定的名稱傳回 PropertyDescriptorReturns 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

參數

name
String String String String

要從集合中傳回的 PropertyDescriptor 名稱。The name of the PropertyDescriptor to return from the collection.

ignoreCase
Boolean Boolean Boolean Boolean

如果您要忽略屬性名稱的大小寫,則為 true,否則為 falsetrue if you want to ignore the case of the property name; otherwise, false.

傳回

具有指定名稱的 PropertyDescriptornull (如果屬性不存在)。A PropertyDescriptor with the specified name, or null if the property does not exist.

範例

下列程式碼範例會尋找特定PropertyDescriptorThe following code example finds a specific PropertyDescriptor. 列印此元件的型別PropertyDescriptor在文字方塊中。It prints the type of component for this PropertyDescriptor in a text box. 它需要button1textBox1具現化表單上。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

適用於

另請參閱