バージョン

SortComparer プロパティ

この列で行をソートする時にカスタム ソート比較を実行するために使用されるプロパティ。IComparer の Compare メソッドで渡される値は、2 つの UltraGridCell オブジェクトです。
シンタックス
'宣言
 
Public Property SortComparer As IComparer
public IComparer SortComparer {get; set;}
解説

この IComparer オブジェクトは、この列で行をソートするために使用されます。

ICompare.Compare で渡される値は、比較を必要とする UltraGridCell オブジェクトです。

GroupByEvaluator が論理的に SortComparer と同じであることを保証することに注意します。たとえば、並べ替えの比較子が大文字と小文字を区別しないソートを行う場合、エバリュエータ ロジックによるグループも大文字と小文字を区別しません。

使用例
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid

  Private Class MySortComparer
      Implements IComparer

      Public Sub New()
      End Sub

      Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare

          ' Passed in objects are cells. So you have to typecast them to UltraGridCell objects first.
          Dim xCell As UltraGridCell = DirectCast(x, UltraGridCell)
          Dim yCell As UltraGridCell = DirectCast(y, UltraGridCell)

          ' Do your own comparision between the values of xCell and yCell and return a negative 
          ' number if xCell is less than yCell, positive number if xCell is greater than yCell, 
          ' and 0 if xCell and yCell are equal.

          ' Following code does an case-insensitive compare of the values converted to string.
          Dim text1 As String = xCell.Value.ToString()
          Dim text2 As String = yCell.Value.ToString()

          Return String.Compare(text1, text2, True)

      End Function

  End Class


  Private Sub Button23_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button23.Click

      Dim band As UltraGridBand = Me.UltraGrid1.DisplayLayout.Bands(0)

      ' Assign an instance of IComparer to SortComparer property.
      band.Columns(0).SortComparer = New MySortComparer()

      ' Sort the column ascending.
      band.SortedColumns.Add(band.Columns(0), False)

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

private class MySortComparer : IComparer 
{
	internal MySortComparer( )
	{
	}

	int IComparer.Compare( object x, object y )
	{

		// Passed in objects are cells. So you have to typecast them to UltraGridCell objects first.
		UltraGridCell xCell = (UltraGridCell)x;
		UltraGridCell yCell = (UltraGridCell)y;

		// Do your own comparision between the values of xCell and yCell and return a negative 
		// number if xCell is less than yCell, positive number if xCell is greater than yCell, 
		// and 0 if xCell and yCell are equal.

		// Following code does an case-insensitive compare of the values converted to string.
		string text1 = xCell.Value.ToString( );
		string text2 = yCell.Value.ToString( );

		return String.Compare( text1, text2, true );

	}
}

private void button23_Click(object sender, System.EventArgs e)
{

	UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0];
	
	// Assign an instance of IComparer to SortComparer property.
	band.Columns[0].SortComparer = new MySortComparer( );

	// Sort the column ascending.
	band.SortedColumns.Add( band.Columns[0], false );

}
参照