🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.pascal.delphi.components
Article #3

Re: TreeView - HELP Help HHHHEEEELLLPPP

#3
From: Clinton R. Johnson
Date: Fri, 08 Aug 1997 00:00
47 lines
1995 bytes

Function FindCreateChild(List : TListView; RootNode : TTreeNode; Text : String) 
: TTreeNode;

Var
  Search                : TTreeNode;

Begin
  Result := Nil;
  Search := RootNode.GetFirstChild;
  While Assigned(Search) Do
  Begin
    If (Search.Text=Text) Then
    Begin
      Result := Search;
      Break;
    End;
    Search := Search.GetNextSibling;
  End;
  If Not Assigned(Result) Then
  Begin
    Result := List.Items.AddChild(RootNode,Text);
  End;
End;

Procedure Aform.AddITems (Names : TStringList);

Var
  Root : TTreeNode;
  Loop : Integer;

Begin
  Root := Nil;      //  I usually define this with an AddFirst call.
  For Loop := 0 To Names.Count-1 Do
  Begin
    Root := CreateAddChild(MyListView,Root,Names[Loop]);
  End;
End;

That should more or less do you.  I use this code myself (the only thing I do 
different, and may cause you difficulties is the assignment of NIL to root,
I normally have it predefined to something already in the tree)

- Clinton R. Johnson

(Now drop the duct tape and the gerbil.... Shesh some people..)
Technical Details
Message-ID: <5sft5o$jc47@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <5sd5s6$3cf$1@titan.globalserve.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 108890,7ec5caf05fc72f13,start
X-Google-Attributes: gid108890,public
X-Google-Thread: 1091e5,7ec5caf05fc72f13,start
X-Google-Attributes: gid1091e5,public
X-Google-Thread: 1043cf,7ec5caf05fc72f13,start
X-Google-Attributes: gid1043cf,public
X-Google-Thread: 10545b,7ec5caf05fc72f13,start
X-Google-Attributes: gid10545b,public
X-Google-Thread: 10baee,7ec5caf05fc72f13,start
X-Google-Attributes: gid10baee,public
From: xepol@canuck.com (Clinton R. Johnson)
Subject: Re: TreeView - HELP Help HHHHEEEELLLPPP
Date: 1997/08/08
Message-ID: <5sft5o$jc47@forums.borland.com>
X-Deja-AN: 262966665
References: <5sd5s6$3cf$1@titan.globalserve.net>
Organization: DDU
Newsgroups: comp.lang.pascal.delphi.components,comp.lang.pascal.delphi.misc,borland.public.delphi.winapi,borland.public.delphi.objectpascal,borland.public.delphi.ide