Version

Reposition(UltraTreeNode,NodePosition) Method

Repositions the node to a specified position in relation to the passed-in RelativeNode.
Syntax
'Declaration
 
Public Overloads Sub Reposition( _
   ByVal relativeNode As UltraTreeNode, _
   ByVal relativePosition As NodePosition _
) 
public void Reposition( 
   UltraTreeNode relativeNode,
   NodePosition relativePosition
)

Parameters

relativeNode
The node that determines this node's new position.
relativePosition
Specifies where this node will be repositioned in relation to RelativeNode.
Remarks

A node can be positioned relative to any other node in the same tree or even a different UltraTree Control.

To reposition a node into an empty UltraTree, use Reposition(TreeNodesCollection).

Note: All of the descendants of the node will move along with it.

Note: A node cannot be repositioned to one of it's own Descendants.

Example
The following sample code illustrates how to change the position of nodes within a tree.

Imports Infragistics.Win.UltraWinTree

Private Sub button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button17.Click

    Dim node As UltraTreeNode

    node = Me.ultraTree1.ActiveNode

    If node Is Nothing Then Return

    ' Check if the active node is a root node.
    If node.IsRootLevelNode Then
        ' If the node is the first root level node
        ' make it the last. Otherwise make it the first.
        If node.Index = 0 Then
            node.Reposition(node, NodePosition.Last)
        Else
            node.Reposition(node, NodePosition.First)
        End If
    Else
        ' Reposition the node by appending it to
        ' the root nodes collection
        node.Reposition(Me.ultraTree1.Nodes)

        ' If the root nodes collection is sorted then
        ' re-sort it so that the repositioned node 
        ' is slotted appropriately.
        If Not Me.ultraTree1.Nodes.SortResolved = SortType.None Then
            Me.ultraTree1.RefreshSort(Me.ultraTree1.Nodes, False)
        End If
    End If

End Sub
using Infragistics.Win.UltraWinTree;

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

	UltraTreeNode node = this.ultraTree1.ActiveNode;

	if ( node == null )
		return;

	// Check if the active node is a root node.
	if ( node.IsRootLevelNode )
	{
		// If the node is the first root level node
		// make it the last. Otherwise make it the first.
		if ( node.Index == 0 )
			node.Reposition( node, NodePosition.Last );
		else
			node.Reposition( node, NodePosition.First );
	}
	else
	{
		// Reposition the node by appending it to
		// the root nodes collection
		node.Reposition( this.ultraTree1.Nodes );

		// If the root nodes collection is sorted then
		// re-sort it so that the repositioned node 
		// is slotted appropriately.
		if ( this.ultraTree1.Nodes.SortResolved != SortType.None )
			this.ultraTree1.RefreshSort(this.ultraTree1.Nodes, false );
	}

}
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