Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get all the childs from treeview

Status
Not open for further replies.

simmo09

Programmer
Apr 22, 2009
82
GB
This is driving me mad, i have my treeview setup something like:

-PARENT1
---aChild1
---aChild2
-PARENT2
---aChild1
---aChild2
---aChild3

..etc..

what i need to do is two things:

1) when i click on PARENT1 OR PARENT2, i need to delete all its childs

2) then add childs under whichever parent was selected, so far i have only got this which adds to the treeview, but everytime i click the parent its duplicating and duplicating:

Code:
DelphiTreeNode:= tvwMain.Selected;

for l:= 0 to lvwMain.Items.Count -1 do
begin
  with tvwMain.Items.AddChild(DelphiTreeNode, lvwMain.Items.Item[l].SubItems[0]) do
  begin
    ImageIndex:= 0;
    SelectedIndex:= 0;
  end;
end;

I think this would be easy if i know how to delete all childs under the parent i select each time.

Thanks
 
I think this would be easy if i know how to delete all childs under the parent i select each time.

Code:
DelphiTreeNode:= tvwMain.Selected;
DelphiTreeNode.DeleteChildren;

Measurement is not management.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top