EventDescriptorCollection 類別

定義

表示 EventDescriptor 物件的集合。

public ref class EventDescriptorCollection : System::Collections::IList
public class EventDescriptorCollection : System.Collections.IList
[System.Runtime.InteropServices.ComVisible(true)]
public class EventDescriptorCollection : System.Collections.IList
type EventDescriptorCollection = class
    interface ICollection
    interface IEnumerable
    interface IList
[<System.Runtime.InteropServices.ComVisible(true)>]
type EventDescriptorCollection = class
    interface IList
    interface ICollection
    interface IEnumerable
[<System.Runtime.InteropServices.ComVisible(true)>]
type EventDescriptorCollection = class
    interface ICollection
    interface IEnumerable
    interface IList
[<System.Runtime.InteropServices.ComVisible(true)>]
type EventDescriptorCollection = class
    interface ICollection
    interface IList
    interface IEnumerable
Public Class EventDescriptorCollection
Implements IList
繼承
EventDescriptorCollection
屬性
實作

範例

下列程式碼範例會在文字方塊中列印按鈕上的所有事件。 它要求 button1 已在表單上具現化 和 textBox1

private:
   void MyEventCollection()
   {
      // Creates a new collection and assigns it the events for button1.
      EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
      
      // Displays each event in the collection in a text box.
      for each ( EventDescriptor^ myEvent in events )
      {
         textBox1->Text = String::Concat( textBox1->Text, myEvent->Name, "\n" );
      }
   }
private void MyEventCollection() {
    // Creates a new collection and assigns it the events for button1.
    EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
 
    // Displays each event in the collection in a text box.
    foreach (EventDescriptor myEvent in events)
       textBox1.Text += myEvent.Name + '\n';
 }
Private Sub MyEventCollection()
    ' Creates a new collection and assigns it the events for button1.
    Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
    
    ' Displays each event in the collection in a text box.
    Dim myEvent As EventDescriptor
    For Each myEvent In  events
        textBox1.Text &= myEvent.Name & ControlChars.Cr
    Next myEvent
End Sub

備註

EventDescriptorCollection 是唯讀的;它不會實作新增或移除事件的方法。 您必須繼承自這個類別,才能實作這些方法。

使用 類別中 EventDescriptorCollection 可用的屬性,您可以查詢集合中有關其內容的資訊。 使用 Count 屬性,判斷集合中的項目數目。 Item[]使用 屬性,依索引編號或名稱取得特定屬性。

您也可以使用 Find 方法,從集合取得具有指定名稱的事件描述。

建構函式

EventDescriptorCollection(EventDescriptor[])

使用 EventDescriptorCollection 物件的指定陣列,初始化 EventDescriptor 類別的新執行個體。

EventDescriptorCollection(EventDescriptor[], Boolean)

使用 EventDescriptorCollection 物件的指定陣列,初始化 EventDescriptor 類別的新執行個體。 可選擇將集合設為唯讀。

欄位

Empty

指定要使用的空集合,而非建立沒有項目的新集合。 這個 static 欄位是唯讀的。

屬性

Count

取得這個集合中事件描述項的數目。

Item[Int32]

取得或設定具有指定索引編號的事件。

Item[String]

取得或設定具有指定名稱的事件。

方法

Add(EventDescriptor)

EventDescriptor 加入至集合結尾。

Clear()

從集合中移除所有物件。

Contains(EventDescriptor)

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

Equals(Object)

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

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

使用集合中之指定名稱取得事件的描述。

GetEnumerator()

取得這個 EventDescriptorCollection 的列舉值。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
IndexOf(EventDescriptor)

傳回指定 EventDescriptor 的索引。

Insert(Int32, EventDescriptor)

EventDescriptor 插入在指定索引處的集合。

InternalSort(IComparer)

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

InternalSort(String[])

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

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Remove(EventDescriptor)

從集合移除指定的 EventDescriptor

RemoveAt(Int32)

從集合中移除位於指定索引位置的 EventDescriptor

Sort()

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

Sort(IComparer)

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

Sort(String[])

提供指定的排序順序,排序這個 EventDescriptorCollection 的成員。

Sort(String[], IComparer)

提供指定的排序順序和 EventDescriptorCollection,排序這個 IComparer 的成員。

ToString()

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

(繼承來源 Object)

明確介面實作

ICollection.CopyTo(Array, Int32)

從特定的 Array 索引開始,將集合的項目複製至 Array

ICollection.Count

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

ICollection.IsSynchronized

取得值,指出是否同步存取集合。

ICollection.SyncRoot

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

IEnumerable.GetEnumerator()

傳回逐一查看集合的列舉值。

IList.Add(Object)

將項目新增至集合。

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

適用於

另請參閱