How to get Text from all Parent Nodes of a Node in TreeView?
<p>Maybe I couldn't explain well, but this should explain:
I have a int field called getParentNode(TreeNode) to get how many parent it has (e.g if there is 2 nodes below node, count will be 2)
And I have a List field called getParentNames(TreeNode) that returns all of the parent's names.</p>

<p><em>getParentCount:</em></p>

<pre><code>int getParentCount(TreeNode node)
{
    int count = 1;
    while (node.Parent != null)
    {
        count++;
        node = node.Parent;
    }
    return count;
}
</code></pre>

<p><em>getParentsNames:</em></p>

<pre><code>List&lt;string&gt; getParentNames(TreeNode node)
{
    List&lt;string&gt; list = new List&lt;string&gt;();
    for (int i = 0; i &lt; getParentCount(node); i++)
    {
        //i = 1 : list.Add(node.Parent.Text);
        //i = 2 : list.Add(node.Parent.Parent.Text);
        //i = 3 ...
    }
    return list;
}
</code></pre>

<p>Do I need to check if (i == 0) (I don't want to write manually because number can be anything) or something?
Regards.</p>