Main Content

move

Move tree node

Description

move(targetnode,siblingnode) moves the target node after the specified sibling node.

example

move(targetnode,siblingnode,location) moves the target node after or before the specified sibling node. Specify location as 'after' or 'before'.

example

Examples

collapse all

Create a tree containing two top-level nodes that each contain a child node.

fig = uifigure;
tree = uitree(fig,'Position',[20 20 200 150]);
node1 = uitreenode(tree,'Text','Runners');
node2 = uitreenode(tree,'Text','Cyclists');
runner = uitreenode(node1,'Text','Joe');
cyclist = uitreenode(node2,'Text','Rajeev');

Tree UI component with two collapsed nodes. The Runners node appears before the Cyclists node.

Move Cyclists before Runners.

move(node2,node1,'before');

Tree UI component with two collapsed nodes. The Cyclists node appears before the Runners node.

Move Cyclists after Runners. Since the default value of location is 'after', you can omit that argument.

move(node2,node1);

Tree UI component with two collapsed nodes. The Runners node appears before the Cyclists node.

Input Arguments

collapse all

Target node, specified as a TreeNode object.

Sibling node, specified as a TreeNode object.

Target location, specified as 'after' or 'before'.

Version History

Introduced in R2017b