Jump to content


Delete Top-Level Selected Node and all Children

Delete Children

  • Please log in to reply
1 reply to this topic

#1 dougwinsby

  • Members
  • 1 posts

Posted 22 May 2019 - 05:13 AM

 I was trying to delete a "selected" top-level node along with all its children (from code).
I first tried: 

But that only deleted some of the children (and of course, not the selected node).
I tried these two other methods, but without success:


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
  oNode := props.Nodes[i];
  if oNode.ParentNode = oParent then oNode.Free;

Am I missing a better way?


#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 7,798 posts
  • Gender:Male

Posted 22 May 2019 - 11:39 PM



It seems that this is a bug. Free should destroy them all. I will work now on quick fix and send you updated code.

boki@bergsoft.net | LinkedIn Profile
BergSoft Home Page: www.bergsoft.net
Members Section: bms.bergsoft.net
Articles and Tutorials: dn.bergsoft.net (Developers Network)
BergSoft Facebook page
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users