Home All Groups Group Topic Archive Search About

TreeNode - find the keys of the node.

Author
5 Jun 2010 12:18 PM
Mr. X.
How can I search a treenode, and get the a specific key & value of the
current searched node.

Thanks :)

Author
7 Jun 2010 1:33 PM
Phill W.
On 05/06/2010 13:18, Mr. X. wrote:

> How can I search a treenode, and get the a specific key & value of the
> current searched node.

Searching Trees is fiddly, because you have to work with their inherent
recursiveness.

What "key" where you hoping to find?  The TreeNode's FullPath property
gives you all the parent names as well (actually, the .Text properties,
concatenated together):

Tree      FullPath

A         A
+- B      A\B
|  +- C   A\B\C
|  +- D   A\B\D
E         E

If you're holding values against each Node, or each Node is a reference
to an object held elsewhere, I would strongly recommend extending the
TreeNode class and adding your own properties to your sub-class.

Class TreeNoad
    Inherits TreeNode

    Public Sub New(byval source as SomeType)
       m_source = source
    End Sub

    Public ReadOnly Property Source() as SomeType
       Get
          Return m_source
       End Get
    End Property

    Private m_source as SomeType = Nothing

End Class

HTH,
    Phill  W.