Version

GroupByComparer Property

Property used for specifying a custom comparer to sort group-by rows.
Syntax
'Declaration
 
Public Property GroupByComparer As IComparer
public IComparer GroupByComparer {get; set;}
Remarks

This IComparer instance will be used for sorting group-by rows associated with this column if this column were a group-by column.

Example
Following code shows how to sort group-by rows using custom sort criteria.

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


    Private Class CustomGroupByRowsSorter
        Implements IComparer

        Private Function Compare(ByVal xObj As Object, ByVal yObj As Object) As Integer Implements IComparer.Compare
            Dim x As UltraGridGroupByRow = DirectCast(xObj, UltraGridGroupByRow)
            Dim y As UltraGridGroupByRow = DirectCast(yObj, UltraGridGroupByRow)

            ' Compare the group rows by the number of items they contain.
            Return x.Rows.Count.CompareTo(y.Rows.Count)
        End Function

    End Class

    Private Sub UltraGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles ultraGrid1.InitializeLayout
        ' Make sure the ViewStyleBand is set to OutlookGroupBy in order to be able
        ' to group rows.
        Me.ultraGrid1.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy
        Me.ultraGrid1.DisplayLayout.Bands(0).SortedColumns.Clear()

        Dim countryCol As UltraGridColumn = Me.ultraGrid1.DisplayLayout.Bands(0).Columns("Country")

        ' Group rows by country column.
        Me.ultraGrid1.DisplayLayout.Bands(0).SortedColumns.Add(countryCol, False, True)

        ' Assign the GroupByComparer to our custom group rows comparer which
        ' we defined above.
        countryCol.GroupByComparer = New CustomGroupByRowsSorter()
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;


		private class CustomGroupByRowsSorter : IComparer
		{
			public int Compare( object xObj, object yObj )
			{
				UltraGridGroupByRow x = (UltraGridGroupByRow)xObj;
				UltraGridGroupByRow y = (UltraGridGroupByRow)yObj;

				// Compare the group rows by the number of items they contain.
				return x.Rows.Count.CompareTo( y.Rows.Count );
			}
		}

		private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e)
		{
			// Make sure the ViewStyleBand is set to OutlookGroupBy in order to be able
			// to group rows.
			this.ultraGrid1.DisplayLayout.ViewStyleBand = ViewStyleBand.OutlookGroupBy;
			this.ultraGrid1.DisplayLayout.Bands[0].SortedColumns.Clear( );
			
			UltraGridColumn countryCol = this.ultraGrid1.DisplayLayout.Bands[0].Columns[ "Country" ];

			// Group rows by country column.
			this.ultraGrid1.DisplayLayout.Bands[0].SortedColumns.Add( countryCol, false, true );

			// Assign the GroupByComparer to our custom group rows comparer which
			// we defined above.
			countryCol.GroupByComparer = new CustomGroupByRowsSorter( );
		}
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