Add and delete Tree nodes with context menu in app designer
    22 ビュー (過去 30 日間)
  
       古いコメントを表示
    
    Jae-Hee Park
 2022 年 6 月 15 日
  
    
    
    
    
    編集済み: Alberto Cuadra Lara
      
 2022 年 6 月 15 日
              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.
0 件のコメント
採用された回答
  Alberto Cuadra Lara
      
 2022 年 6 月 15 日
        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 件のコメント
  Alberto Cuadra Lara
      
 2022 年 6 月 15 日
				
      編集済み: Alberto Cuadra Lara
      
 2022 年 6 月 15 日
  
			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 件)
参考
カテゴリ
				Help Center および File Exchange で Develop Apps Using App Designer についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

