How to deselect a checkbox/node in a checkboxtree programmatically
29 次查看(过去 30 天)
显示 更早的评论
Hi,
I am using the new prerelease of MATLAB 2022a. For my current project in App Designer I found the checkboxtree-component.
While I integrate this component in my GUI I was wondering how to deactivate checkboxes of single nodes by
code ?
There is nothing explained in the documentation.
0 个评论
采纳的回答
Benjamin Thompson
2022-2-2
In my particular mlapp example, if you set a breakpoint on the button push handler you can query the Tree checked nodes property:
app.Tree.CheckedNodes
ans =
4×1 TreeNode array:
TreeNode (Node)
TreeNode (Node2)
TreeNode (Node3)
TreeNode (Node4)
K>> app.Tree.CheckedNodes(2)
ans =
TreeNode (Node2) with properties:
Text: 'Node2'
Icon: ''
NodeData: []
Show all properties
So all four nodes are checked. This is the parent plus three children. In the tree selection change handler you could easily alter the CheckedNodes property for the tree:
app.Tree.CheckedNodes = app.Tree.CheckedNodes(2)
This changes the selection to just the first child node. You may have already done this type of thing in your solution, but you can easily expand on this example for your particular requirements.
0 个评论
更多回答(1 个)
Benjamin Thompson
2022-2-1
Not sure whether you mean unchecking any of the checked boxes or deselecting. In the check box utiree, only one node can be selected. The uittree object has properties SelectedNodes and CheckedNotes. You just need to clear the one you want:
app.Tree.SelectedNodes = [];
app.Tree.CheckedNodes = [];
I attached an app demonstrating this.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Environment and Settings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!