how to use tree in app designer

조회 수: 31 (최근 30일)
pipor
pipor 2023년 9월 8일
편집: Adam Danz 2023년 9월 8일
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

답변 (2개)

Shoresh Shokoohi
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
Adam Danz 2023년 9월 8일
SelectedNodes indicates which nodes are currently selected (in blue, below), not which nodes are checked.

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


Adam Danz
Adam Danz 2023년 9월 8일
편집: Adam Danz 2023년 9월 8일
Look in app.Tree_Equity.CheckedNodes.
SelectedNodes indicates which nodes are currently selected (in blue, below), not which nodes are checked.

카테고리

Help CenterFile 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!

Translated by