TreeNode - find the keys of the node.

M

Mr. X.

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

Thanks :)
 
P

Phill W.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top