PropertyDescriptorCollection PropertyDescriptorCollection PropertyDescriptorCollection PropertyDescriptorCollection Class

定義

表示 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
繼承
PropertyDescriptorCollectionPropertyDescriptorCollectionPropertyDescriptorCollectionPropertyDescriptorCollection
實作

範例

下列程式碼範例會建立新PropertyDescriptorCollection使用上的屬性button1The 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 'MyPropertyCollection 

備註

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(PropertyDescriptor[]) PropertyDescriptorCollection(PropertyDescriptor[]) PropertyDescriptorCollection(PropertyDescriptor[])

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

PropertyDescriptorCollection(PropertyDescriptor[], Boolean) PropertyDescriptorCollection(PropertyDescriptor[], Boolean) PropertyDescriptorCollection(PropertyDescriptor[], Boolean) PropertyDescriptorCollection(PropertyDescriptor[], Boolean)

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

欄位

Empty Empty Empty 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 Count Count Count

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

Item[Int32] Item[Int32] Item[Int32] Item[Int32]

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

Item[String] Item[String] Item[String] Item[String]

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

方法

Add(PropertyDescriptor) Add(PropertyDescriptor) Add(PropertyDescriptor) Add(PropertyDescriptor)

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

Clear() Clear() Clear() Clear()

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

Contains(PropertyDescriptor) Contains(PropertyDescriptor) Contains(PropertyDescriptor) Contains(PropertyDescriptor)

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

CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32) CopyTo(Array, Int32)

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

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

(Inherited from Object)
Find(String, Boolean) Find(String, Boolean) Find(String, Boolean) Find(String, Boolean)

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

GetEnumerator() GetEnumerator() GetEnumerator() GetEnumerator()

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

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

(Inherited from Object)
IndexOf(PropertyDescriptor) IndexOf(PropertyDescriptor) IndexOf(PropertyDescriptor) IndexOf(PropertyDescriptor)

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

Insert(Int32, PropertyDescriptor) Insert(Int32, PropertyDescriptor) Insert(Int32, PropertyDescriptor) Insert(Int32, PropertyDescriptor)

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

InternalSort(IComparer) InternalSort(IComparer) InternalSort(IComparer) InternalSort(IComparer)

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

InternalSort(String[]) InternalSort(String[]) InternalSort(String[]) 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() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
Remove(PropertyDescriptor) Remove(PropertyDescriptor) Remove(PropertyDescriptor) Remove(PropertyDescriptor)

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

RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32) RemoveAt(Int32)

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

Sort() Sort() Sort() Sort()

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

Sort(IComparer) Sort(IComparer) Sort(IComparer) Sort(IComparer)

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

Sort(String[]) Sort(String[]) Sort(String[]) 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) Sort(String[], IComparer) Sort(String[], IComparer) 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() ToString() ToString() ToString()

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

(Inherited from Object)

明確介面實作

ICollection.Count ICollection.Count ICollection.Count ICollection.Count

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

ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized ICollection.IsSynchronized

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

ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot ICollection.SyncRoot

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

IDictionary.Add(Object, Object) IDictionary.Add(Object, Object) IDictionary.Add(Object, Object) IDictionary.Add(Object, Object)

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

IDictionary.Clear() IDictionary.Clear() IDictionary.Clear() IDictionary.Clear()

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

IDictionary.Contains(Object) IDictionary.Contains(Object) IDictionary.Contains(Object) IDictionary.Contains(Object)

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

IDictionary.GetEnumerator() IDictionary.GetEnumerator() IDictionary.GetEnumerator() IDictionary.GetEnumerator()

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

IDictionary.IsFixedSize IDictionary.IsFixedSize IDictionary.IsFixedSize IDictionary.IsFixedSize

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

IDictionary.IsReadOnly IDictionary.IsReadOnly IDictionary.IsReadOnly IDictionary.IsReadOnly

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

IDictionary.Item[Object] IDictionary.Item[Object] IDictionary.Item[Object] IDictionary.Item[Object]

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

IDictionary.Keys IDictionary.Keys IDictionary.Keys IDictionary.Keys

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

IDictionary.Remove(Object) IDictionary.Remove(Object) IDictionary.Remove(Object) IDictionary.Remove(Object)

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

IDictionary.Values IDictionary.Values IDictionary.Values IDictionary.Values

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

IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator() IEnumerable.GetEnumerator()

傳回 IEnumeratorIDictionaryReturns an IEnumerator for the IDictionary.

IList.Add(Object) IList.Add(Object) IList.Add(Object) IList.Add(Object)

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

IList.Clear() IList.Clear() IList.Clear() IList.Clear()

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

IList.Contains(Object) IList.Contains(Object) IList.Contains(Object) IList.Contains(Object)

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

IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object) IList.IndexOf(Object)

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

IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object) IList.Insert(Int32, Object)

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

IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize IList.IsFixedSize

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

IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly IList.IsReadOnly

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

IList.Item[Int32] IList.Item[Int32] IList.Item[Int32] IList.Item[Int32]

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

IList.Remove(Object) IList.Remove(Object) IList.Remove(Object) IList.Remove(Object)

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

IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32) IList.RemoveAt(Int32)

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

Extension Methods

Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable) Cast<TResult>(IEnumerable)

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

OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable) OfType<TResult>(IEnumerable)

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

AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable) AsParallel(IEnumerable)

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

AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable) AsQueryable(IEnumerable)

將轉換IEnumerableIQueryableConverts an IEnumerable to an IQueryable.

適用於

另請參閱