TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
nitin 0
NA
18
0
TreeView Control Performance REALLY LOW on searching a Node
Jan 30 2004 5:14 AM
I have more than 20, 000 nodes , parent node having sub nodes and again subnodes exactly like windows explorer structure with files and folders. I populate the tree on "afterexpand" event by passing the parentnodeid and getting child nodes. The problem is with the search, suppose I want to search a particular node I check the Tag property of currentnode to my searchnode and search recursively but the problem is since I donot have treeview loaded I have to call tnode.expand() to populate the parentnode with chlid nodes and then I see if Tag property of my search node matches one by one with child nodes, if not drill to sub levels further and do the same. To expand each node one by one and check for search node takes hell lot of time. Can anyone suggest better way .Here is the code below public void SearchRecursive(TreeNode ParentNode, TreeNode MyTreeNode) { foreach (TreeNode tNode in ParentNode.Nodes) { if (tNode.Tag.ToString() == MyTreeNode.Tag.ToString()) { this.treeView1.SelectedNode = tNode; this.treeView1.SelectedNode.EnsureVisible(); break; } else { tNode.Expand(); if (tNode.GetNodeCount(true) > 0) SearchRecursive(tNode,MyTreeNode); } } }
Reply
Answers (
5
)
Display Alerts like MSN AND YAHOO.
Launching a Windows Forms App from a web browser with parameters