Version

SortComparer Property (Override)

Gets/sets the sort comparer that is used to determine how UltraTreeNode objects are sorted.
Syntax
'Declaration
 
Public Property SortComparer As IComparer
public IComparer SortComparer {get; set;}
Remarks

The SortComparer determines how nodes are sorted.

The default SortComparer will sort nodes alphabetically based on the Text property of the node. The direction of the sort is determined by the Sort property of the Override.

The SortComparer property can be set to any object which implements the System.Collections.IComparer interface. The x and y objects of the Compare method will be the two UltraTreeNodes being compared.

When creating a custom SortComparer, nodes should always be sorted Ascendingly. The UltraTree will reverse the order when Sort is set to Descending.

The SortComparer property of the UltraTreeNodeOverride is ignored.

Example
The following sample code illustrates how to specify the sort order of nodes.

Imports Infragistics.Win.UltraWinTree

Private Sub button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button10.Click

    ' Note: the Override objects are exposed as properties off
    ' the tree, the node and the nodes collection as well as
    ' items in the NodeLevelOverrides collection. This allows
    ' default settings to be specified for the tree, a node, 
    ' a node's children or for a level in the tree.

    ' Use the tree's Override property to
    ' set the default for all nodes.
    Me.ultraTree1.Override.Sort = SortType.Descending

    ' You can optionally provide your own object that 
    ' implements the System.Collections.IComparer interface.
    ' Note: differnt comparers can be specified at 
    ' various levels/parent nodes in the tree.
    'Me.ultraTree1.Override.SortComparer = new MySortComparer()

    ' Set the default for nodes that are at level 2 
    ' (i.e. grandchild nodes of root modes).
    ' This overrides the default setting above.
    Me.ultraTree1.NodeLevelOverrides(2).Sort = SortType.Ascending

    ' Set the default for nodes at the root level. 
    ' This overrides the default settings above.
    Me.ultraTree1.Nodes.Override.Sort = SortType.None

    Dim node As UltraTreeNode

    ' Get a specific node by its key value. 
    ' Note: this will return the node that has that key
    ' from anywhere in the tree structure since keys are
    ' unique across the entire tree.
    node = Me.ultraTree1.GetNodeByKey("child node 1")

    ' Set the property for that specific node only.
    ' This overrides any default settings above.
    node.Override.Sort = SortType.Ascending

    ' Set the property for that specific node's child nodes
    node.Nodes.Override.Sort = SortType.Ascending

End Sub
using Infragistics.Win.UltraWinTree;

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

	// Note: the Override objects are exposed as properties off
	// the tree, the node and the nodes collection as well as
	// items in the NodeLevelOverrides collection. This allows
	// default settings to be specified for the tree, a node, 
	// a node's children or for a level in the tree.

	// Use the tree's Override property to
	// set the default for all nodes.
	this.ultraTree1.Override.Sort = SortType.Descending;
	
	// You can optionally provide your own object that 
	// implements the System.Collections.IComparer interface.
	// Note: differnt comparers can be specified at 
	// various levels/parent nodes in the tree.
	//this.ultraTree1.Override.SortComparer = new MySortComparer();
		
	// Set the default for nodes that are at level 2 
	// (i.e. grandchild nodes of root modes).
	// This overrides the default setting above.
	this.ultraTree1.NodeLevelOverrides[2].Sort = SortType.Ascending;

	// Set the default for nodes at the root level. 
	// This overrides the default settings above.
	this.ultraTree1.Nodes.Override.Sort = SortType.None;

	// Get a specific node by its key value. 
	// Note: this will return the node that has that key
	// from anywhere in the tree structure since keys are
	// unique across the entire tree.
	UltraTreeNode node = this.ultraTree1.GetNodeByKey("child node 1");

	// Set the property for that specific node only.
	// This overrides any default settings above.
	node.Override.Sort = SortType.Ascending;

	// Set the property for that specific node's child nodes
	node.Nodes.Override.Sort = SortType.Ascending;
		
}
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