Results 1 to 6 of 6

Thread: Problems with TreeView

Hybrid View

  1. #1

    Thread Starter
    Member UConnVendetta's Avatar
    Join Date
    Jul 2003
    Location
    Madison, CT, USA
    Posts
    36

    Question 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?
    Jazzman Will Rosenberg
    Chief Admin of [Vendetta]
    http://vendetta.n3.com
    AIM: UConnVendetta, CollegeGuy184

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985
    for root it would be
    VB Code:
    1. ProjectName = "Project "
    2. projectTreeView.Nodes.Add(ProjectName)

    That creates the root node(top node)

    Then this creates another branch off to the right
    VB Code:
    1. 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:
    1. 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

  3. #3

    Thread Starter
    Member UConnVendetta's Avatar
    Join Date
    Jul 2003
    Location
    Madison, CT, USA
    Posts
    36
    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.) ?
    Jazzman Will Rosenberg
    Chief Admin of [Vendetta]
    http://vendetta.n3.com
    AIM: UConnVendetta, CollegeGuy184

  4. #4

    Thread Starter
    Member UConnVendetta's Avatar
    Join Date
    Jul 2003
    Location
    Madison, CT, USA
    Posts
    36
    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
    Jazzman Will Rosenberg
    Chief Admin of [Vendetta]
    http://vendetta.n3.com
    AIM: UConnVendetta, CollegeGuy184

  5. #5
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    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.

  6. #6

    Thread Starter
    Member UConnVendetta's Avatar
    Join Date
    Jul 2003
    Location
    Madison, CT, USA
    Posts
    36

    thanks

    that really helps out a lot.
    Jazzman Will Rosenberg
    Chief Admin of [Vendetta]
    http://vendetta.n3.com
    AIM: UConnVendetta, CollegeGuy184

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width