Results 1 to 5 of 5

Thread: Tree View Help

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2003
    Location
    Eden Prairie Minnesota
    Posts
    301

    Tree View Help

    I use this function to add nodes

    VB Code:
    1. Public Function AddTree(ByVal Name, ByVal Capt, ByVal PC)
    2.  
    3. Dim NodeC As Variant
    4.  
    5.     Select Case PC
    6.      
    7.         Case "P"
    8.            
    9.             Set NN = TreeSetup.Nodes.Add(, , Name, Capt)
    10.              
    11.         Case "C"
    12.  
    13.             NodeC = NodeC & NodeC
    14.             Set NN = TreeSetup.Nodes.Add(Name, tvwChild, NodeC, Capt)
    15.              
    16.     End Select
    17.      
    18.  End Function

    and i have these for my Nodes:

    VB Code:
    1. AddTree "Main", "Global", "P"
    2.  
    3. AddTree "Main1", "Battle.net", "P"
    4. AddTree "Main1", "Login", "C"
    5. AddTree "Main1", "Options", "C"
    6.  
    7. AddTree "Main2", "Bot Options", "P"
    8. AddTree "Main2", "Anti-Idle", "C"
    9. AddTree "Main2", "Filters", "C"
    10. AddTree "Main2", "GUI", "C"

    Code:
    But it ends up Showing like
    
    Global
              [-]Battle.net
                        Login
                        Options
              [+]Bot Options
                        Anti-Idle
                        Filters
                        GUI
    
    
    But i want it Like
    
    [-]Global
              [+]Battle.Net
              [-]Bot Options
                        Anti-Idle
                        Filters
                        GUI
    I want to be able to Collapse Global, but it won't let me >_<!!!!

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Your Main1 and Main2 nodes need to be Children of the Global node.

    Why the function? It doesn't really do anything useful, you can just add the new nodes directly(unless you are not showing the entire code).

    VB Code:
    1. Private Sub Command1_Click()
    2.     AddTree "Main", "Global"
    3.    
    4.     AddTree "Main1", "Battle.net", "Main"
    5.     AddTree "", "Login", "Main1"
    6.     AddTree "", "Options", "Main1"
    7.    
    8.     AddTree "Main2", "Bot Options", "Main"
    9.     AddTree "", "Anti-Idle", "Main2"
    10.     AddTree "", "Filters", "Main2"
    11.     AddTree "", "GUI", "Main2"
    12.  
    13. End Sub
    14. Public Function AddTree(ByVal Key As String, ByVal Caption As String, Optional ByVal ParentKey As String = "")
    15.  
    16.     If ParentKey = "" Then
    17.         Set NN = TreeView1.Nodes.Add(, , Key, Caption)
    18.     Else
    19.    
    20.         Set NN = TreeView1.Nodes.Add(ParentKey, tvwChild, Key, Caption)
    21.     End If
    22.  End Function

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2003
    Location
    Eden Prairie Minnesota
    Posts
    301
    i have 2 more questions/favors to ask

    How would i go about telling it to make a frame visibile when a certain node is Highlighted and not visibile when it's not highlighted?

  4. #4
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    VB Code:
    1. Private Sub TreeView1_NodeClick(ByVal Node As MSComctlLib.Node)
    2.  
    3.     If TreeView1.SelectedItem.Key = "something" Then ' You could also use .Text
    4.         MyFrame.Visible = True
    5.     Else
    6.         MyFrame.Visible = False
    7.     End If
    8.  
    9.  
    10. End Sub

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    Right click your listview, click properties, and set LineStyle to Root Lines
    Remember, if someone's post was not helpful, you can always rate their post negatively .

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