|
-
Oct 5th, 2007, 04:29 PM
#1
Thread Starter
Hyperactive Member
[2005] TreeNode For Each
I'm having issues with iteriating treenodes.
I've got a database table with the following columns:
CategoryID
CategoryName
ParentID
I set the Node name to CategoryID and the .Tag property to the ParentID.
Items with ParentID = 0, Tag is Nothing.
Now, I iteriate through nodes and start moving them around:
Code:
For Each mNode As TreeNode In control.Nodes
If Not IsNothing(mNode.Tag) Then
mNode.Remove()
'control.Nodes(mNode.Tag.ToString).Nodes.Add(mNode)
MsgBox(mNode.Tag)
control.Nodes(control.Nodes.IndexOfKey(mNode.Tag)).Nodes.Add(mNode)
End If
Next
The issue is that for some reason, it won't add more than 2 child nodes to a parent. Even though the data is right.
Heres what the result looks like:
+ Windows
-Security
-Productivity
+ Ubuntu
-Design
+Tools
Heres what is should be:
+ Windows
-Security
-Productivity
-Tools
+Ubuntu
-Design
-
Oct 5th, 2007, 04:36 PM
#2
Re: [2005] TreeNode For Each
What happens when you code encounters the Tools node? What is the Tools node's tag property set to?
-
Oct 5th, 2007, 04:39 PM
#3
Thread Starter
Hyperactive Member
Re: [2005] TreeNode For Each
2, which is what Windows is set to.
I cleared out the rows and now I'm finding more issues.
-
Oct 6th, 2007, 12:17 AM
#4
Thread Starter
Hyperactive Member
Re: [2005] TreeNode For Each
Well, I kinda of figured it out, I just looped through the For Each like 10 times, which is not the best way, but it works for now.
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
|