Main Content

move

Move tree node

Description

example

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'.

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');

Move Cyclists before Runners.

move(node2,node1,'before');

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

move(node2,node1);

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'.

Introduced in R2017b