PropertyDescriptorCollection 類別

定義

表示 PropertyDescriptor 物件的集合。

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 IEnumerable
    interface IDictionary
    interface IList
type PropertyDescriptorCollection = class
    interface IList
    interface IDictionary
    interface ICollection
    interface IEnumerable
type PropertyDescriptorCollection = class
    interface ICollection
    interface IEnumerable
    interface IList
    interface IDictionary
Public Class PropertyDescriptorCollection
Implements IDictionary, IList
繼承
PropertyDescriptorCollection
實作

範例

下列程式碼範例會使用 上的 button1 屬性建立新的 PropertyDescriptorCollection 。 它需要 button1 已在表單上具現化。

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

下一個範例會在文字方塊中列印按鈕上的所有屬性。 它要求 button1 已在表單上具現化 和 textBox1

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 可用的屬性,您可以查詢集合中有關其內容的資訊。 使用 Count 屬性,判斷集合中的項目數目。 Item[]使用 屬性,依索引編號或名稱取得特定屬性。

除了屬性之外,您還可以使用 Find 方法,從集合中取得具有指定名稱的屬性描述。

建構函式

PropertyDescriptorCollection(PropertyDescriptor[])

初始化 PropertyDescriptorCollection 類別的新執行個體。

PropertyDescriptorCollection(PropertyDescriptor[], Boolean)

初始化 PropertyDescriptorCollection 類別的新執行個體,可以選擇這個類別是否為唯讀。

欄位

Empty

指定您可以使用的空集合,而不必建立沒有項目的新集合。 這個 static 欄位是唯讀的。

屬性

Count

取得這個集合中屬性描述項的數目。

Item[Int32]

取得或設定在指定索引編號的 PropertyDescriptor

Item[String]

取得或設定具有指定之名稱的 PropertyDescriptor

方法

Add(PropertyDescriptor)

將指定的 PropertyDescriptor 加入至集合。

Clear()

從集合中移除所有 PropertyDescriptor 物件。

Contains(PropertyDescriptor)

傳回值,表示集合是否含有指定的 PropertyDescriptor

CopyTo(Array, Int32)

將整個集合複製至陣列,開始於指定的索引編號。

Equals(Object)

判斷指定的物件是否等於目前的物件。

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

使用布林值 (Boolean) 指示是否忽略大小寫,並以指定的名稱傳回 PropertyDescriptor

GetEnumerator()

傳回這個類別的列舉值。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IndexOf(PropertyDescriptor)

傳回指定 PropertyDescriptor 的索引。

Insert(Int32, PropertyDescriptor)

在指定的索引編號將 PropertyDescriptor 加入集合。

InternalSort(IComparer)

使用指定的 IComparer,排序這個集合的成員。

InternalSort(String[])

排序這個集合的成員。 首先會套用指定的順序,其後是這個集合的預設排序,通常是依字母順序。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Remove(PropertyDescriptor)

從集合移除指定的 PropertyDescriptor

RemoveAt(Int32)

從集合中移除指定索引處的 PropertyDescriptor

Sort()

使用這個集合的預設排序,通常是依字母順序,排序這個集合的成員。

Sort(IComparer)

使用指定的 IComparer,排序這個集合的成員。

Sort(String[])

排序這個集合的成員。 首先會套用指定的順序,其後是這個集合的預設排序,通常是依字母順序。

Sort(String[], IComparer)

排序這個集合的成員。 首先會套用指定的順序,其後是使用指定 IComparer 的排序。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

ICollection.Count

取得集合所包含的項目數目。

ICollection.IsSynchronized

取得值,表示是否同步化存取集合 (執行緒安全)。

ICollection.SyncRoot

取得物件,這個物件可以用來對集合進行同步存取。

IDictionary.Add(Object, Object)

將隨附有索引鍵和值的項目加入至 IDictionary

IDictionary.Clear()

移除 IDictionary 中的所有項目。

IDictionary.Contains(Object)

判斷 IDictionary 是否包含具有指定之索引鍵的項目。

IDictionary.GetEnumerator()

傳回這個類別的列舉值。

IDictionary.IsFixedSize

取得值,指出 IDictionary 是否有固定的大小。

IDictionary.IsReadOnly

取得值,指出 IDictionary 是否唯讀。

IDictionary.Item[Object]

取得或設定具有指定索引鍵的項目。

IDictionary.Keys

取得 ICollection,包含 IDictionary 的索引鍵。

IDictionary.Remove(Object)

將有指定索引鍵的項目從 IDictionary 移除。

IDictionary.Values

取得 ICollection,包含 IDictionary 中的值。

IEnumerable.GetEnumerator()

傳回 IEnumeratorIDictionary

IList.Add(Object)

將項目加入至 IList

IList.Clear()

移除集合的所有項目。

IList.Contains(Object)

判斷此集合是否包含特定的值。

IList.IndexOf(Object)

判斷集合中指定項目的索引。

IList.Insert(Int32, Object)

在指定的索引位置,插入項目至集合之中。

IList.IsFixedSize

取得值,這個值表示集合的大小是否是固定的。

IList.IsReadOnly

取得值,表示集合是否為唯讀。

IList.Item[Int32]

從集合中取得或設定在指定索引的項目。

IList.Remove(Object)

從集合中移除指定值的第一個符合項目。

IList.RemoveAt(Int32)

移除指定之索引處的項目。

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。

AsParallel(IEnumerable)

啟用查詢的平行化作業。

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryable

適用於

另請參閱