PropertyDescriptorCollection 類別

定義

表示 PropertyDescriptor 物件的集合。Represents a collection of PropertyDescriptor objects.

public ref class PropertyDescriptorCollection : System::Collections::IDictionary, System::Collections::IList
public class PropertyDescriptorCollection : System.Collections.IDictionary, System.Collections.IList
type PropertyDescriptorCollection = class
    interface ICollection
    interface IList
    interface IDictionary
    interface IEnumerable
Public Class PropertyDescriptorCollection
Implements IDictionary, IList
繼承
PropertyDescriptorCollection
實作

範例

下列程式碼範例會使用上PropertyDescriptorCollection button1的屬性來建立新的。The following code example creates a new PropertyDescriptorCollection using the properties on button1. 它需要button1已經在表單上具現化。It requires that button1 has been instantiated on a form.

PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);
Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(button1)

下一個範例會在文字方塊中列印按鈕上的所有屬性。The next example prints all the properties on a button in a text box. 它需要button1textBox1已經在表單上具現化。It requires that button1 and textBox1 have been instantiated on a form.

private:
   void MyPropertyCollection()
   {
      // Creates a new collection and assign it the properties for button1.
      PropertyDescriptorCollection^ properties = TypeDescriptor::GetProperties( button1 );
      
      // Displays each property in the collection in a text box.
      for each ( PropertyDescriptor^ myProperty in properties )
      {
         textBox1->Text = String::Concat( textBox1->Text, myProperty->Name, "\n" );
      }
   }
private void MyPropertyCollection() {
    // Creates a new collection and assign it the properties for button1.
    PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(button1);
 
    // Displays each property in the collection in a text box.
    foreach (PropertyDescriptor myProperty in properties)
       textBox1.Text += myProperty.Name + '\n';
 }
Private Sub MyPropertyCollection()
    ' Creates a new collection and assign it the properties for button1.
    Dim properties As PropertyDescriptorCollection = TypeDescriptor.GetProperties(button1)
    
    ' Displays each property in the collection in a text box.
    Dim myProperty As PropertyDescriptor
    For Each myProperty In  properties
        textBox1.Text &= myProperty.Name & ControlChars.Cr
    Next myProperty
End Sub

備註

PropertyDescriptorCollection是唯讀的;它不會執行新增或移除屬性的方法。PropertyDescriptorCollection is read-only; it does not implement methods that add or remove properties. 您必須繼承自這個類別,才能執行這些方法。You must inherit from this class to implement these methods.

您可以使用PropertyDescriptorCollection類別中的可用屬性,查詢其內容的集合。Using the properties available in the PropertyDescriptorCollection class, you can query the collection about its contents. 使用 Count 屬性,判斷集合中的項目數目。Use the Count property to determine the number of elements in the collection. Item[String]使用屬性,依索引編號或名稱取得特定屬性。Use the Item[String] property to get a specific property by index number or by name.

除了屬性之外,您還可以使用Find方法,從集合中取得具有指定名稱之屬性的描述。In addition to properties, you can use the Find method to get a description of the property with the specified name from the collection.

建構函式

PropertyDescriptorCollection(PropertyDescriptor[])

初始化 PropertyDescriptorCollection 類別的新執行個體。Initializes a new instance of the PropertyDescriptorCollection class.

PropertyDescriptorCollection(PropertyDescriptor[], Boolean)

初始化 PropertyDescriptorCollection 類別的新執行個體,可以選擇這個類別是否為唯讀。Initializes a new instance of the PropertyDescriptorCollection class, which is optionally read-only.

欄位

Empty

指定您可以使用的空集合,而不必建立沒有項目的新集合。Specifies an empty collection that you can use instead of creating a new one with no items. 這個 static 欄位是唯讀的。This static field is read-only.

屬性

Count

取得這個集合中屬性描述項的數目。Gets the number of property descriptors in the collection.

Item[Int32]

取得或設定在指定索引編號的 PropertyDescriptorGets or sets the PropertyDescriptor at the specified index number.

Item[String]

取得或設定具有指定之名稱的 PropertyDescriptorGets or sets the PropertyDescriptor with the specified name.

方法

Add(PropertyDescriptor)

將指定的 PropertyDescriptor 加入至集合。Adds the specified PropertyDescriptor to the collection.

Clear()

從集合中移除所有 PropertyDescriptor 物件。Removes all PropertyDescriptor objects from the collection.

Contains(PropertyDescriptor)

傳回值,表示集合是否含有指定的 PropertyDescriptorReturns whether the collection contains the given PropertyDescriptor.

CopyTo(Array, Int32)

將整個集合複製至陣列,開始於指定的索引編號。Copies the entire collection to an array, starting at the specified index number.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Find(String, Boolean)

使用布林值 (Boolean) 指示是否忽略大小寫,並以指定的名稱傳回 PropertyDescriptorReturns the PropertyDescriptor with the specified name, using a Boolean to indicate whether to ignore case.

GetEnumerator()

傳回這個類別的列舉值。Returns an enumerator for this class.

GetHashCode()

作為預設雜湊函數。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
IndexOf(PropertyDescriptor)

傳回指定 PropertyDescriptor 的索引。Returns the index of the given PropertyDescriptor.

Insert(Int32, PropertyDescriptor)

在指定的索引編號將 PropertyDescriptor 加入集合。Adds the PropertyDescriptor to the collection at the specified index number.

InternalSort(IComparer)

使用指定的 IComparer,排序這個集合的成員。Sorts the members of this collection, using the specified IComparer.

InternalSort(String[])

排序這個集合的成員。Sorts the members of this collection. 首先會套用指定的順序,其後是這個集合的預設排序,通常是依字母順序。The specified order is applied first, followed by the default sort for this collection, which is usually alphabetical.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
Remove(PropertyDescriptor)

從集合移除指定的 PropertyDescriptorRemoves the specified PropertyDescriptor from the collection.

RemoveAt(Int32)

從集合中移除指定索引處的 PropertyDescriptorRemoves the PropertyDescriptor at the specified index from the collection.

Sort()

使用這個集合的預設排序,通常是依字母順序,排序這個集合的成員。Sorts the members of this collection, using the default sort for this collection, which is usually alphabetical.

Sort(IComparer)

使用指定的 IComparer,排序這個集合的成員。Sorts the members of this collection, using the specified IComparer.

Sort(String[])

排序這個集合的成員。Sorts the members of this collection. 首先會套用指定的順序,其後是這個集合的預設排序,通常是依字母順序。The specified order is applied first, followed by the default sort for this collection, which is usually alphabetical.

Sort(String[], IComparer)

排序這個集合的成員。Sorts the members of this collection. 首先會套用指定的順序,其後是使用指定 IComparer 的排序。The specified order is applied first, followed by the sort using the specified IComparer.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

明確介面實作

ICollection.Count

取得集合所包含的項目數目。Gets the number of elements contained in the collection.

ICollection.IsSynchronized

取得值,表示是否同步化存取集合 (執行緒安全)。Gets a value indicating whether access to the collection is synchronized (thread safe).

ICollection.SyncRoot

取得物件,這個物件可以用來對集合進行同步存取。Gets an object that can be used to synchronize access to the collection.

IDictionary.Add(Object, Object)

將具有提供索引鍵和值的元素加入至 IDictionaryAdds an element with the provided key and value to the IDictionary.

IDictionary.Clear()

移除 IDictionary 中的所有項目。Removes all elements from the IDictionary.

IDictionary.Contains(Object)

判斷 IDictionary 是否包含具有指定之索引鍵的項目。Determines whether the IDictionary contains an element with the specified key.

IDictionary.GetEnumerator()

傳回這個類別的列舉值。Returns an enumerator for this class.

IDictionary.IsFixedSize

取得值,指出 IDictionary 是否有固定的大小。Gets a value indicating whether the IDictionary has a fixed size.

IDictionary.IsReadOnly

取得值,指出 IDictionary 是否唯讀。Gets a value indicating whether the IDictionary is read-only.

IDictionary.Item[Object]

取得或設定具有指定索引鍵的項目。Gets or sets the element with the specified key.

IDictionary.Keys

取得 ICollection,包含 IDictionary 的索引鍵。Gets an ICollection containing the keys of the IDictionary.

IDictionary.Remove(Object)

IDictionary 中移除具有指定之索引鍵的項目。Removes the element with the specified key from the IDictionary.

IDictionary.Values

取得 ICollection,包含 IDictionary 中的值。Gets an ICollection containing the values in the IDictionary.

IEnumerable.GetEnumerator()

傳回 IEnumeratorIDictionaryReturns an IEnumerator for the IDictionary.

IList.Add(Object)

將項目加入至 IListAdds an item to the IList.

IList.Clear()

移除集合的所有項目。Removes all items from the collection.

IList.Contains(Object)

判斷此集合是否包含特定的值。Determines whether the collection contains a specific value.

IList.IndexOf(Object)

判斷集合中指定項目的索引。Determines the index of a specified item in the collection.

IList.Insert(Int32, Object)

在指定的索引位置,插入項目至集合之中。Inserts an item into the collection at a specified index.

IList.IsFixedSize

取得值,這個值表示集合的大小是否是固定的。Gets a value indicating whether the collection has a fixed size.

IList.IsReadOnly

取得值,表示集合是否為唯讀。Gets a value indicating whether the collection is read-only.

IList.Item[Int32]

從集合中取得或設定在指定索引的項目。Gets or sets an item from the collection at a specified index.

IList.Remove(Object)

從集合中移除指定值的第一個符合項目。Removes the first occurrence of a specified value from the collection.

IList.RemoveAt(Int32)

移除在指定索引處的項目。Removes the item at the specified index.

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱