Board index » delphi » How to check if a TreeNode is on the "first level" of a TreeView?

How to check if a TreeNode is on the "first level" of a TreeView?

Hi,

I have the following problem:

I have a TreeView with some Nodes and I want to get all Nodes on the
top level... Let's show an example:

+-T1
|    +---T11
|    +---T12
+-T2
|    +---T21
+-T3

I want to get the nodes T1, T2 and T3...

a

for i:=0 to TreeView1.Items.Count-1 do
  something

returns _all_ nodes... so I have to check if it's a top item before
doing something...

How can I do this?
If you can help me, please mail to <h0444...@rz.hu-berlin.de>! Thank
you!

bye...
Alexander

___________________________________________________________________
Alexander Lucke                 ps...@ra.psychologie.hu-berlin.de
                                        CIS 106322,1002
                                        http://141.20.111.4/al

ATTENTION!!!    I have trouble with the above email accounts. At the
                moment please send email only to
                        <h0444...@rz.hu-berlin.de>
                (or Cc it to this address)!

 

Re:How to check if a TreeNode is on the "first level" of a TreeView?


Hi Alexander,

The TTreeNodes have methods to return specific Nodes.

So from the top of my head:

procedure Proc;
  var aNode : TTreeNode;
begin
  aNode := TreeView1.Items[0];  //Get First Node (Root)
  repeat
    {
       DoSomething with aNode here
    }  
    aNode := aNode.GetNextSibling;      //Get Next Node on same level
  until aNode = nil;                    //until no more
end;

Alexander Lucke <ps...@ra.psychologie.hu-berlin.de> wrote in article
<56t4ce$...@suncom.rz.hu-berlin.de>...

Quote
> Hi,

> I have the following problem:

> I have a TreeView with some Nodes and I want to get all Nodes on the
> top level... Let's show an example:

> +-T1
> |    +---T11
> |    +---T12
> +-T2
> |    +---T21
> +-T3

> I want to get the nodes T1, T2 and T3...

> a

>> Snip! <<

Other Threads