I was trying to delete a "selected" top-level node along with all its children (from code).
I first tried:
props.SelectedNode.ClearChildren;
But that only deleted some of the children (and of course, not the selected node).
I tried these two other methods, but without success:
props.Nodes.ClearChildren(oNode); propsPriceSheet.Nodes.Delete(0);
If finally tried something like the following, which worked, but seems more difficult than it should be:
oParent := props.SelectedNode; for i:= pred(props.Nodes.Count) downto 0 do begin oNode := props.Nodes[i]; if oNode.ParentNode = oParent then oNode.Free; end; oParent.Free;
Am I missing a better way?