Board index » delphi » ttreeview - list of child nodes (using recursion)

ttreeview - list of child nodes (using recursion)

does anyone out there have a snippet of code which recursively captures the
'text' of the selected node, as well as all subordinate nodes to the one
selected?  subordinate nodes may also have children and their 'text' will
need to be captured also.

please reply to this group, and also to pal...@fred.net (if possible).

...thanks in advance,  patrick
--
patrick allen
caplen
jefferson, maryland  usa

 

Re:ttreeview - list of child nodes (using recursion)


WEll, hmmm, what exactly are you looking for? Be a little more specific. You
may not even need to recurse depending on what you want. What should the INPUTS
be for this magical function and what should the OUTPUTS be??

Davie

Quote
Patrick Allen wrote:
> does anyone out there have a snippet of code which recursively captures the
> 'text' of the selected node, as well as all subordinate nodes to the one
> selected?  subordinate nodes may also have children and their 'text' will
> need to be captured also.

> please reply to this group, and also to pal...@fred.net (if possible).

> ...thanks in advance,  patrick
> --
> patrick allen
> caplen
> jefferson, maryland  usa

Re:ttreeview - list of child nodes (using recursion)


the treeview displays a hierarchy of animal classifications and categories.
 a partial example would be:

horses
  |--draft
  |    |--percheron
  |    |--clydesdale
  |--american
       |--mustang

when the user selects a parent node (horses), then i want to be able to
capture the 'text' of each of the subordinate nodes in order to build a
query statement programmatically...such as:

node=horses or node=draft or node=percheron or node=clydesdale or
node=american or node=mustang

...patrick
--
patrick allen
the caplen company
jefferson, maryland  usa
pal...@fred.net

Davie Reed <da...@smatters.com> wrote in article
<385ABEA5.3C851...@smatters.com>...

Quote
> WEll, hmmm, what exactly are you looking for? Be a little more specific.
You
> may not even need to recurse depending on what you want. What should the
INPUTS
> be for this magical function and what should the OUTPUTS be??

> Davie

> Patrick Allen wrote:

> > does anyone out there have a snippet of code which recursively captures
the
> > 'text' of the selected node, as well as all subordinate nodes to the
one
> > selected?  subordinate nodes may also have children and their 'text'
will
> > need to be captured also.

> > please reply to this group, and also to pal...@fred.net (if possible).

> > ...thanks in advance,  patrick
> > --
> > patrick allen
> > caplen
> > jefferson, maryland  usa

Re:ttreeview - list of child nodes (using recursion)


Quote
> does anyone out there have a snippet of code which recursively captures the
> 'text' of the selected node, as well as all subordinate nodes to the one
> selected?  subordinate nodes may also have children and their 'text' will
> need to be captured also.

You would use a loop like this:

  var
    node: TTreeNode;

  node:= Treeview.Items[0];
  while node <> nil do begin
    ..do something with node.text, check node.level to see which level
      the node belongs to
    node:= node.GetNext;
  end;

Using GetNext you get a "depth-first" traversal of the tree of nodes, which
is what you asked for, i think.  

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads