Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
    Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles UltraGrid1.InitializeLayout
        ' Set AllowRowSummaries to allow the user to select summaries.
        Me.UltraGrid1.DisplayLayout.Override.AllowRowSummaries = AllowRowSummaries.True
    End Sub
    Private Sub UltraGrid1_AfterSummaryDialog(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.AfterSummaryDialogEventArgs) Handles UltraGrid1.AfterSummaryDialog
        ' SummariesChanged property indicates if the user modified any summaries.
        If e.SummariesChanged And 0 = e.Column.Band.Index Then
            ' Find out if the user cleared the summaries for the column.
            Dim summariesCleared As Boolean = True
            Dim summary As SummarySettings
            For Each summary In e.Column.Band.Summaries
                ' If there is a summary with the source column of the column the user 
                ' modified the summaries on then the user did not clear the summaries 
                ' for the column.
                If summary.SourceColumn Is e.Column Then
                    summariesCleared = False
                    Exit For
                End If
            Next
            ' At this point the user has selected a new summary. To make the summary area
            ' visible, we need to scroll the last visible row into view.
            If Not summariesCleared Then
                Dim lastVisibleRow As UltraGridRow = Me.UltraGrid1.Rows.GetRowAtVisibleIndex(Me.UltraGrid1.Rows.VisibleRowCount - 1)
                Me.UltraGrid1.ActiveRowScrollRegion.ScrollRowIntoView(lastVisibleRow)
            End If
        End If
    End Sub