how to use tree in app designer
32 ビュー (過去 30 日間)
古いコメントを表示
i want to know what is selected or not:
Jow is not selected
Linda is not selected
where can i find this information? ...
this my code in callBack
function Tree_EquitySelectionChanged(app, event)
nodes = app.Tree_Equity.SelectedNodes;
if ~isempty(nodes)
data = [nodes.NodeData];
display(sum(data));
disp(data)
end
end
0 件のコメント
回答 (2 件)
Shoresh Shokoohi
2023 年 9 月 8 日
The code you've provided seems to correctly identify the selected nodes and display some information about them.
Here's a breakdown of your code:
1. `app.Tree_Equity.SelectedNodes` retrieves a list of selected nodes in the `Tree_Equity` tree component.
2. The `if ~isempty(nodes)` condition checks if there are any selected nodes. If there are selected nodes, it proceeds to the next steps.
3. `data = [nodes.NodeData];` extracts the data associated with each selected node. This assumes that each node has a `NodeData` property that contains relevant information.
4. `display(sum(data));` calculates the sum of the data associated with selected nodes and displays it. This step may not be necessary for your specific task, as it doesn't directly relate to determining which nodes are selected.
5. `disp(data)` displays the data associated with each selected node in the command window.
The information you want to extract from the selected nodes is not entirely clear from your code, but you are correctly accessing the selected nodes and displaying the associated data.
If you want to determine which specific nodes are selected and whether their data indicates selection status (e.g., "selected" or "not selected"), you need to examine the structure of the `data` associated with each node. Ensure that the `NodeData` property of each node contains the necessary information to identify whether it is selected or not, and then adjust your code accordingly.
1 件のコメント
Adam Danz
2023 年 9 月 8 日
SelectedNodes indicates which nodes are currently selected (in blue, below), not which nodes are checked.
参考
カテゴリ
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!