TreeNode - find the keys of the node.

  • Thread starter Thread starter Mr. X.
  • Start date Start date
M

Mr. X.

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

Thanks :)
 
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.
 
Back
Top