EventDescriptorCollection.GetEnumerator 方法    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取此 EventDescriptorCollection 的枚举器。
public:
 System::Collections::IEnumerator ^ GetEnumerator();
	public:
 virtual System::Collections::IEnumerator ^ GetEnumerator();
	public System.Collections.IEnumerator GetEnumerator ();
	member this.GetEnumerator : unit -> System.Collections.IEnumerator
	abstract member GetEnumerator : unit -> System.Collections.IEnumerator
override this.GetEnumerator : unit -> System.Collections.IEnumerator
	Public Function GetEnumerator () As IEnumerator
	返回
实现 IEnumerator 的枚举数。
实现
示例
下面的代码示例获取 上 button1事件的枚举器。 它使用 枚举器打印集合中事件的名称。 它要求 button1 和 textBox1 已在窗体上实例化。
private:
   void MyEnumerator()
   {
      // Creates a new collection, and assigns to it the events for button1.
      EventDescriptorCollection^ events = TypeDescriptor::GetEvents( button1 );
      
      // Creates an enumerator.
      IEnumerator^ ie = events->GetEnumerator();
      
      // Prints the name of each event in the collection.
      Object^ myEvent;
      while ( ie->MoveNext() == true )
      {
         myEvent = ie->Current;
         textBox1->Text = String::Concat( textBox1->Text, myEvent, "\n" );
      }
   }
private void MyEnumerator() {
    // Creates a new collection, and assigns to it the events for button1.
    EventDescriptorCollection events = TypeDescriptor.GetEvents(button1);
 
    // Creates an enumerator.
    IEnumerator ie = events.GetEnumerator();
 
    // Prints the name of each event in the collection.
    Object myEvent;
    while(ie.MoveNext() == true) {
       myEvent = ie.Current;
       textBox1.Text += myEvent.ToString() + '\n';
    }
 }
Private Sub MyEnumerator()
    ' Creates a new collection, and assigns to it the events for button1.
    Dim events As EventDescriptorCollection = TypeDescriptor.GetEvents(button1)
    
    ' Creates an enumerator.
    Dim ie As IEnumerator = events.GetEnumerator()
    
    ' Prints the name of each event in the collection.
    Dim myEvent As Object
    While ie.MoveNext() = True
        myEvent = ie.Current
        textBox1.Text += myEvent.ToString() & ControlChars.Cr
    End While
End Sub
	注解
注意
HostProtectionAttribute应用于此类的属性具有以下Resources属性值:Synchronization。 HostProtectionAttribute 不影响桌面应用程序(通常通过双击图标、键入命令或在浏览器中输入 URL 来启动这些应用程序)。 有关详细信息,请参阅 HostProtectionAttribute 类或SQL Server编程和主机保护属性。