I'm trying to select all the child node of a parent node when the parent is clicked, but when I for each node set the Selected = true i only end up with the last one being selected. MultiSelect is true and I can do it with the mouse, so the setup should be ok.
For testing I use this code:
TTreeNode *node = Tv->Items->GetFirstNode();
node->Selected = true;
node = node->GetNext();
node->Selected = true;
node = node->GetNext();
node->Selected = true;
node = node->GetNext();
node->Selected = true;
Any tricks to make this work?
The
TTreeNode::Selectedproperty does not support multiple selections when toggling the node's selection state. Internally, it will call the Win32TreeView_SelectItem()API, which selects a single node only.For multi-select, use the
TTreeView::Select()method instead:That being said, your example is attempting to select (potentially) every node in the TreeView, not just the child nodes of a parent node, as you claim.
Try this: