Version

Band Property (BeforeSortChangeEventArgs)

The band (read-only)
Syntax
'Declaration
 
Public ReadOnly Property Band As UltraGridBand
public UltraGridBand Band {get;}
Example
The following code illustrates some of the information available in the BeforeSortChange event and its potential uses.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Sub UltraGrid1_BeforeSortChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.BeforeSortChangeEventArgs) Handles ultraGrid1.BeforeSortChange

      ' The BeforeSortChange event fires when the user sorts rows by a column
      ' or groups rows by a column. So you can use BeforeSortChange event to control
      ' how the user sort rows as well as groups rows. The SortedColumns parameter off 
      ' the passed in event args contains all the group-by columns and sort 
      ' columns (in that order).

      Dim i As Integer
      Dim numberOfGroupByColumns As Integer = 0

      ' TIP: Group-by columns are always before any non-group-by columns in the
      ' SortedColumnsCollection. (Even if the group-by columns were added
      ' after adding non-group-by columns).

      ' Find out the number of group by columns by traversing the sorted columns
      ' collection.
      For i = 0 To e.SortedColumns.Count - 1
          If (e.SortedColumns(i).IsGroupByColumn) Then
              numberOfGroupByColumns += 1
          Else
              Exit For
          End If
      Next

      ' You can cancel the event so the grid won't proceed with the changes.
      If numberOfGroupByColumns > 2 Then
          ' Enforce the user to have no more than 2 group-by columns.
          e.Cancel = True
          Return
      End If

	' The ProcessMode property of the BeforeSortChangeEventArgs event argument provides the ability
	' to specify whether sorting and filtering of rows will occur synchronously or lazily.
	' This can be usefull in situations where the grid contains a large number of records
	' and the developer wishes to display a wait cursor during the sort.  By default the grid applies
	' sorting and filtering lazily to rows in each band as it is expanded.  If the ProccessMode property
	' is set to either Synchronous or SynchronousExpanded the developer can ensure that either all rows
	' in all bands, or all expanded rows in all bands are synchronously sorted and filtered, i.e., all at once.
	' If a more fine grained approach is desired the RowsCollection overloaded EnsureSortedAndFiltered method
	' can be used to specify how far down in the hierarchy of bands synchronous sorting and filtering should be applied.

	' Setting the ProcessMode to Lazy specifies that the grid should apply sorting and filtering lazily
	' to rows in each band as it is expanded.  This is the default behavior of the grid.
	e.ProcessMode = ProcessMode.Lazy

	' Setting the ProcessMode to Synchronous specifies that the grid should apply sorting and filtering
	' synchronously to all rows in all bands.
	e.ProcessMode = ProcessMode.Synchronous

	' Setting the ProcessMode to SynchronousExpanded specifies that the grid should apply sorting and filtering
	' synchronously to all expanded rows in all bands.
	e.ProcessMode = ProcessMode.SynchronousExpanded

	' This code specifies that a wait cursor should be displayed during a sort and ensures that all rows in all
	' bands are sorted while the wait cursor is displayed.  The cursor should be reset in the grid's AfterSortChange
	' event.
	e.ProcessMode = ProcessMode.Synchronous
	Me.ultraGrid1.Cursor = Cursors.WaitCursor

  End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;

private void ultraGrid1_BeforeSortChange(object sender, Infragistics.Win.UltraWinGrid.BeforeSortChangeEventArgs e)
{

	// The BeforeSortChange event fires when the user sorts rows by a column
	// or groups rows by a column. So you can use BeforeSortChange event to control
	// how the user sort rows as well as groups rows. The SortedColumns parameter off 
	// the passed in event args contains all the group-by columns and sort 
	// columns (in that order).
	
	int i;
	int numberOfGroupByColumns = 0;

	// TIP: Group-by columns are always before any non-group-by columns in the
	// SortedColumnsCollection. (Even if the group-by columns were added
	// after adding non-group-by columns).

	// Find out the number of group by columns by traversing the sorted columns
	// collection.
	for ( i = 0; i < e.SortedColumns.Count; i++ )
	{
		if ( e.SortedColumns[ i ].IsGroupByColumn )
			numberOfGroupByColumns++;
		else 
			break;
	}

	// You can cancel the event so the grid won't proceed with the changes.
	if ( numberOfGroupByColumns > 2 )
	{
		// Enfore the user only have no more than 2 group-by columns.
		e.Cancel = true;
		return;
	}

	// The ProcessMode property of the BeforeSortChangeEventArgs event argument provides the ability
	// to specify whether sorting and filtering of rows will occur synchronously or lazily.
	// This can be usefull in situations where the grid contains a large number of records
	// and the developer wishes to display a wait cursor during the sort.  By default the grid applies
	// sorting and filtering lazily to rows in each band as it is expanded.  If the ProccessMode property
	// is set to either Synchronous or SynchronousExpanded the developer can ensure that either all rows
	// in all bands, or all expanded rows in all bands are synchronously sorted and filtered, i.e., all at once.
	// If a more fine grained approach is desired the RowsCollection overloaded EnsureSortedAndFiltered method can be used
	// to specify how far down in the hierarchy of bands synchronous sorting and filtering should be applied.

	// Setting the ProcessMode to Lazy specifies that the grid should apply sorting and filtering lazily
	// to rows in each band as it is expanded.  This is the default behavior of the grid.
	e.ProcessMode = ProcessMode.Lazy;

	// Setting the ProcessMode to Synchronous specifies that the grid should apply sorting and filtering
	// synchronously to all rows in all bands.
	e.ProcessMode = ProcessMode.Synchronous;

	// Setting the ProcessMode to SynchronousExpanded specifies that the grid should apply sorting and filtering
	// synchronously to all expanded rows in all bands.
	e.ProcessMode = ProcessMode.SynchronousExpanded;

	// This code specifies that a wait cursor should be displayed during a sort and ensures that all rows in all
	// bands are sorted while the wait cursor is displayed.  The cursor should be reset in the grid's AfterSortChange
	// event.
	e.ProcessMode = ProcessMode.Synchronous;
	this.ultraGrid1.Cursor = Cursors.WaitCursor;

}
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also