asp.net.ph

DataGridColumnCollection.GetEnumerator Method

System.Web.UI.WebControls Namespace   DataGridColumnCollection Class


Returns an IEnumerator interface that contains all the DataGridColumn objects in the collection.

[ VB ]
NotOverridable Public Function GetEnumerator ( ) As IEnumerator

[ C# ]
public IEnumerator GetEnumerator ( );

[ C++ ]
public: __sealed IEnumerator* GetEnumerator ( );

[ JScript ]
public function GetEnumerator ( ) : IEnumerator;

Return Value

A System.Collections.IEnumerator that contains a list of DataGridColumn objects in the collection.

Remarks

Use this method to create a System.Collections.IEnumerator that can be iterated through easily to get each item in the DataGridColumnCollection.

Use the IEnumerator.Current property to get the item currently pointed to in the collection.

Use the IEnumerator.MoveNext method to move to the next item in the collection.

Use the IEnumerator.Reset method to move the enumerator to the initial position.

NOTE: The IEnumerator.MoveNext method must be called after creating a System.Collections.IEnumerator object, or after using the IEnumerator.Reset method to move the enumerator to the first item in the collection. Otherwise, the item represented by the IEnumerator.Current property is undefined.

Example

The following example demonstrates how to use the GetEnumerator method to create an IEnumerator interface that can be interated though to display the contents of the DataGridColumnCollection.

void getEnumerator ( Object src, EventArgs e ) {
   // create IEnumerator for rows.
   IEnumerator myEnum = myGrid.Columns.GetEnumerator ( );
   DataGridColumn column;
   myLabel.Text = "The header text of the items in the IEnumerator are: <p>";

   // iterate through IEnumerator and display its contents.
   while ( myEnum.MoveNext ( ) ) {
      column = ( DataGridColumn ) myEnum.Current;
      myLabel.Text += column.HeaderText + "<br>";
   }
}
  C# VB

See Also

DataGridColumnCollection Members Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph