Add and delete Tree nodes with context menu in app designer

Hi!
I am making an app using app designer.
There is a uitree, and I was able to create a child node of that uitree through the add button like below.
function buttonPushed(app,event)
app.TreeNode = uitreenode(app.Scenario1Node);
end
But after creating multiple nodes, I can't figure out how to remove the selected node.
What should I do?
My goal is that when creating a node, the contextmenu of the node is also created, and the contextmenu has a function to delete the selected node.
please help me! Thank you.

 채택된 답변

Hi Jae-Hee,
You can delete the node directly as follows
% Remove node of UITree
delete(app.TreeNode)
% If you want to remove only its children use
delete(app.TreeNode.Children)

댓글 수: 2

when I want to delete just one Children Node, how can I select that node and delete?
To obtain the selected nodes use the SelectedNodes property of the object Tree
delete(app.Tree.SelectedNodes);
To delete a particular position of the TreeNode array use
delete(app.TreeNode.Children(3))

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Develop Apps Programmatically에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by