Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Private Sub Button40_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button40.Click
Dim rowsCount As Integer = 0
Dim groupByRowsCount As Integer = 0
' Call the helper method which is a recursive implmentation for traversing rows.
MessageBox.Show("Please wait. This operation may take a while depending on number of rows.")
Me.TraverseAllRowsHelper(Me.ultraGrid1.Rows, rowsCount, groupByRowsCount)
' Show a dialog showing the number of regular rows and number of group-by rows.
MessageBox.Show("The UltraGrid has " & rowsCount & " number of regular rows, and " & groupByRowsCount & " number of group-by rows.")
End Sub
Private Sub TraverseAllRowsHelper(ByVal rows As RowsCollection, ByRef rowsCount As Integer, ByRef groupByRowsCount As Integer)
' Loop through every row in the passed in rows collection.
Dim row As UltraGridRow = Nothing
For Each row In rows
' If you are using Outlook GroupBy feature and have grouped rows by columns in the
' UltraGrid, then rows collection can contain group-by rows or regular rows. So you
' may need to have code to handle group-by rows as well.
If TypeOf row Is UltraGridGroupByRow Then
Dim groupByRow As UltraGridGroupByRow = DirectCast(row, UltraGridGroupByRow)
' Incremement the group-by row count.
groupByRowsCount += 1
Else
' Incremenent the regular row count.
rowsCount += 1
End If
' If the row has any child rows. Typically, there is only a single child band. However,
' there will be multiple child bands if the band associated with row1 has mupliple child
' bands. This would be the case for exmple when you have a database hierarchy in which a
' table has multiple child tables.
If Not Nothing Is row.ChildBands Then
' Loop throgh each of the child bands.
Dim childBand As UltraGridChildBand = Nothing
For Each childBand In row.ChildBands
' Call this method recursivedly for each child rows collection.
Me.TraverseAllRowsHelper(childBand.Rows, rowsCount, groupByRowsCount)
Next
End If
Next
End Sub