|
-
Jul 13th, 2005, 04:13 PM
#1
Thread Starter
New Member
How do I update TreeView lists?
I have a situation that I have two treeviews that start with:
TreeView1.Nodes.Add("Plan")
TreeView1.Nodes(0).Nodes.Add("SDP")
TreeView1.Nodes(0).Nodes.Add("BIP")
and:
TreeView2.Nodes.Add("Plan")
Treeview2.Nodes(0).Nodes.Add("SDP").
When the program runs, it needs to remove from TreeView1 all items common to both treeviews and keep in TreeView2 all items common to both.
In other words, after the program runs, the TreeView1 should show:
Plan
.BIP
and TreeView2 should show:
Plan
.SDP
I need help in writing the code for this operation!
Thanks!
Mike Fowler
-
Jul 13th, 2005, 09:12 PM
#2
Re: How do I update TreeView lists?
Pretty much whenever you are traversing a tree you should use recursion (methods that call themselves). If you know that your trees will only be one level deep then recursion is not really necessary, but in the general case recursion is the way to go. If you don't know what recursion is then I'd suggest you do some reading on the subject. You would need to write two recursive functions. One to traverse each tree. I'd suggest that you start with tree2. Go to each node in turn and then search tree1 for a matching node. If you find a match, remove it from tree1. If you don't find a match, remove the node from tree2. Once you've traversed all of tree2 in this manner your trees will be in the state you require.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|