Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
120
Counting nodes and elements in WinTree
posted

Hi,

is it possible to count togehter each nodes and elements in a WinTree for each Level?

Sample:

Level0_Node            (0 / 2)
---Level1_Node1       (2 / 3)
-------Element1
-------Element2
-------Level2_Node1   (3)
---------- Element1
---------- Element2
---------- Element3   
-------Level2_Node2   (0)
-------Level2_Node3   (0)
---Level1_Node2       (2)
-------Element1
-------Element2

After each node, there should be a bracket (). The first value should be the number of elements right under that node, and the second value should be the number of subnodes under this node.

How could I do this?

Is there a counting function in the WinTree?

Best regards,

Rene

  • 469350
    Suggested Answer
    Offline posted

    Hi Rene,

    I'm not sure what you mean by a "counting function". The tree would not know which nodes you wanted to count. You can get the number of child nodes for any node examining node.Nodes.Count. You could loop through the nodes and it's children to get the count of the grandchild nodes. You would probably want to write a recurcive function to do this, so it accounts for all levels.