Version

SortComparer Property (UltraTreeNodeColumn)

Gets/sets the IComparer implementor that is determines the order in which nodes which display this column appear in their respective Nodes collections when this UltraTreeNodeColumn is sorted.
Syntax
'Declaration
 
Public Property SortComparer As IComparer
public IComparer SortComparer {get; set;}
Example
The following code sample demonstrates how the UltraTreeNodeColumn's SortComparer property can be used to sort data while ignoring certain characters, for example, parentheses.

Imports Infragistics.Win
Imports Infragistics.Win.Layout
Imports Infragistics.Win.UltraWinTree


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim rootColumnSet As UltraTreeColumnSet = Me.ultraTree1.ColumnSettings.RootColumnSet
        rootColumnSet.Columns("CompanyName").SortComparer = New CustomSortComparer()
    End Sub

Public Class CustomSortComparer
    Implements IComparer

    Public Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
        Dim cellX As UltraTreeNodeCell = x
        Dim cellY As UltraTreeNodeCell = y

        Dim stringX As String = cellX.Text
        Dim stringY As String = cellY.Text

        stringX = stringX.Replace("(", String.Empty)
        stringX = stringX.Replace(")", String.Empty)

        stringY = stringY.Replace("(", String.Empty)
        stringY = stringY.Replace(")", String.Empty)

        Return stringX.CompareTo(stringY)

    End Function
End Class
using Infragistics.Win;
using Infragistics.Win.Layout;
using Infragistics.Win.UltraWinTree;
using System.Diagnostics;

		private void button1_Click(object sender, System.EventArgs e)
		{
			UltraTreeColumnSet rootColumnSet = this.ultraTree1.ColumnSettings.RootColumnSet;
			rootColumnSet.Columns["CompanyName"].SortComparer = new CustomSortComparer();
		}

	public class CustomSortComparer : IComparer
	{
		int IComparer.Compare( object x, object y )
		{
			UltraTreeNodeCell cellX = x as UltraTreeNodeCell;
			UltraTreeNodeCell cellY = y as UltraTreeNodeCell;

			string stringX = cellX.Text;
			string stringY = cellY.Text;

			stringX = stringX.Replace( "(", string.Empty );
			stringX = stringX.Replace( ")", string.Empty );

			stringY = stringY.Replace( "(", string.Empty );
			stringY = stringY.Replace( ")", string.Empty );

			return stringX.CompareTo( stringY );
		}
	}
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