I was looking for a way to search for an item in a treeview in C#. I used the following question/answer TreeView search and it works great. The only issue I'm having now is that I can only look through nodes that have been expanded at least once. So I added a ExpandAll() and Collapse() to the Load event of my form so that I can find any item anywhere in the tree. But now, I'm dealing with very big hierarchies and it takes 45+ seconds to load my dialog box because of that expandAll() call. Is there a way to do that search without calling expandAll() first? Thanks a lot.
Asked
Active
Viewed 542 times
0
-
Separate the model from the view. – Hans Passant Jul 14 '15 at 00:21
-
Are you planning to show the item found placing it on the tree view or just show the single item like a search result? – Andrew Paes Jul 14 '15 at 12:36
-
Yes, I need to show the item(s) found in the tree. The search button selects the next item that matches the searched string. I think I need to perform the search in the data I use to build the tree instead of searching in the tree. Is that what you suggest @HansPassant? – Mcartel Jul 15 '15 at 00:56