Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview Search

Status
Not open for further replies.

deulyd

Programmer
Oct 17, 2001
106
0
0
CA
Hi,
does anyone has an algorythm to search in a treeview using a recursive proc.

I can't use the nodes collection of the treeview with a "for...next" because the nodes in the collection are not ordered as in the treeview.

Thanks

Deulyd
 
No that doesn't work, because the nodes aren't sorted by as in the visual treeview in the collection. It would find the nodes in a weird order using the collection.
 
deulyd,

In these instances I use the Nodes collection in a For Each loop and a For Each to go through the collection. You do not loose much time by doing it this way.
for example. If I have a collection named g_Col Then I would work the situation as follows.

Dim oObj as <name of class in the collection>

dim nodX as node

for each nodX in tree1.nodes
for each oObj in g_Col
if oObj.identifier = nodX.key Then
'enter transactional code here.
end if
next
next


I only worry about how they are sorted in the tree. The sorting of the collection could be made asyncronous with the tree, but then you are taking extra steps. Remember that you can always access the parent and child nodes of the nodX that is it looking at by useing .parent or .child. That will also allow you to make sure you are looking at the right place.


Cheers,
blweb
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top