views:

573

answers:

1

What is the best method to loop through TreeView nodes and retrieve a node based on certain value?

+2  A: 

It would more efficient to create something like a Dictionary<string, TreeNode> and add all the nodes in it. This of course must be done at the start of the form or whenever you add new tree nodes. The dictionary key can be anything e.g TreeNode Text or business object associated with the node.

You won't need to traverse through all the nodes - just use the search criteria (key) and retrieve the node.

Vivek