Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

AttributeCollection::GetEnumerator Method ()

 

Gets an enumerator for this collection.

Namespace:   System.ComponentModel
Assembly:  System (in System.dll)

public:
IEnumerator^ GetEnumerator()

Return Value

Type: System.Collections::IEnumerator^

An enumerator of type IEnumerator.

The following code example gets an enumerator for the attributes on button1. It uses the enumerator to print the names of the attributes in the collection. It assumes that button1 and textBox1 have been created on a form.

private:
   void MyEnumerator()
   {
      // Creates a new collection and assigns it the attributes for button1.
      AttributeCollection^ attributes;
      attributes = TypeDescriptor::GetAttributes( button1 );

      // Creates an enumerator for the collection.
      System::Collections::IEnumerator^ ie = attributes->GetEnumerator();

      // Prints the type of each attribute in the collection.
      Object^ myAttribute;
      System::Text::StringBuilder^ text = gcnew System::Text::StringBuilder;
      while ( ie->MoveNext() == true )
      {
         myAttribute = ie->Current;
         text->Append( myAttribute );
         text->Append( '\n' );
      }
      textBox1->Text = text->ToString();
   }

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft