Version

Looping Through the Entire Grid

The GetRowEnumerator method makes it easy to loop through the entire WinGrid™ in order to search for or change a specific row. The GetRowEnumerator method was added to the UltraGridBand class to loop through all the rows in a particular band. The method was also added to the RowsCollection class to loop through all rows in a particular rows collection. The code below shows two Foreach loops. The part of the example shows looping through a band. The second part of the example demonstrates looping through a collection of rows.

In Visual Basic:

Imports Infragistics.Win.UltraWinGrid
...
' This feature is particularly useful for child bands because previously
' looping through all the rows of a child band required writing a recursive
' method.
Dim band As UltraGridBand = Me.UltraGrid1.DisplayLayout.Bands(1)
Dim row As UltraGridRow
For Each row In band.GetRowEnumerator(GridRowType.DataRow)
	' Write code to process the row
Next row
' This will loop through all the rows of the grid, including rows
' from child bands.
Dim row As UltraGridRow
For Each row In  Me.UltraGrid1.Rows.GetRowEnumerator(GridRowType.DataRow, Nothing, Nothing)
	' Write code to process the row
Next row

In C#:

using Infragistics.Win.UltraWinGrid;
...
// This feature is particularly useful for child bands because previously
// looping through all the rows of a child band required writing a recursive
// method.
UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[1];
foreach (UltraGridRow row in band.GetRowEnumerator(GridRowType.DataRow))
{
	// Write code to process the row
}
// This will loop through all the rows of the grid, including rows
// from child bands.
foreach ( UltraGridRow row in this.ultraGrid1.Rows.GetRowEnumerator( GridRowType.DataRow, null, null ) )
{
	// Write code to process the row
}