|
-
Jul 27th, 2003, 12:17 AM
#1
Thread Starter
Member
Problems with TreeView
I'm trying to make a Link Loader for a popular online game, KingsOfChaos.com, where one of the ways you can increase your army is by having people click on your "secret link".
I set up my treeview with my commander/officer hierarchy and checkboxes in front of each node. I currently have it set so that when the user double-clicks on a node a browser window opens and loads the link.
I want to be able to set it so that users can click on the checkboxes of those players's links they wish to follow and then click a submit button. That button will go through the tree and find which nodes are checked and load my linkloader sub for node checked.
I also want to make a button that will check all of the nodes and one that will uncheck all of the nodes.
The problem I'm running into is that each subtree is individually indexed, i.e.:
[ ] Index 0
|
|--[ ] Index 0
|
|--[ ] Index 1
|
|--[ ] Index 2
| |
| |--[ ] Index 0
| |
| |--[ ] Index 1
|
|--[ ] Index 3
and I'm not sure how make the program recognize which node is which and which is checked. Any ideas?
-
Jul 27th, 2003, 12:37 AM
#2
for root it would be
VB Code:
ProjectName = "Project "
projectTreeView.Nodes.Add(ProjectName)
That creates the root node(top node)
Then this creates another branch off to the right
VB Code:
projectTreeView.Nodes(0).Nodes.Add(FileNames)
That's how you create nodes, basic when you want to move right to another branch, you use nodes(0)(Or whatever the index number is, like if they're 2 nodes in 1 node)
You just keep on adding .Nodes.Example
VB Code:
TreeView1.Nodes(0).Nodes(1).Nodes.Add(NodeName)
That would go from
Root
||
||
||==
||
||==NodeName
See where I'm going?
Sorry, I'm not very good at explaining things, lol
I know I just showed you how to add new nodes, but it's basicly the same concept with working with them and stuff
-
Jul 27th, 2003, 01:11 AM
#3
Thread Starter
Member
I see what you're getting at with:
Code:
TreeView1.Nodes(0).Nodes(1).Nodes.Add(NodeName)
Is there a way to find out how many subtrees there are (treeview1.nodes(0).nodes(0).nodes(0)...etc.) ?
-
Jul 27th, 2003, 01:15 AM
#4
Thread Starter
Member
and for that matter how many nodes are in each subtree, cuz if so i could just make a for/next loop and easily take care of it
-
Jul 27th, 2003, 01:50 AM
#5
All SelectedNodes are in the Selected or CheckedNodes collection regardless of where they are at in the heirarchy. Also to retrieve or loop through all the nodes you'd need to use a recursive function (a function that calls itself if further work is needed). Another bit of advise use the Tag property to store whatever object is supposed to be represented in the node then just refer to it directly through the tag property instead of trying to find it in another collection or something of that nature.
-
Jul 27th, 2003, 12:25 PM
#6
Thread Starter
Member
thanks
that really helps out a lot.
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
|