dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: [RESOLVED] TreeView Problems - Expand All TreeNodes and +/- Not Displaying

  1. #1
    Join Date
    Jun 2006
    Posts
    194

    [RESOLVED] TreeView Problems - Expand All TreeNodes and +/- Not Displaying

    2 Questions: I have a TreeView (below) and I want all the nodes to be expanded when the form first loads. What is the code for that? Also, I created the TreeView and set the property Style = tvwTreelinesPlusMinusText, but the Pluses and Minuses do not show when the application executes, any ideas why it wouldn't??? Thanks

    Code:
    Private Sub Form_Load()
        TreeView1.nodes.Add , , "root", "A Symbols"
        TreeView1.nodes.Add "root", tvwChild, , "x1"
        TreeView1.nodes.Add "root", tvwChild, , "x2"
        TreeView1.nodes.Add "root", tvwChild, , "x3"
        TreeView1.nodes.Add "root", tvwChild, , "x4"
        TreeView1.nodes.Add "root", tvwChild, , "x5"
        TreeView1.nodes.Add "root", tvwChild, , "x6"
        TreeView1.nodes.Add "root", tvwChild, , "x7"
        TreeView1.nodes.Add "root", tvwChild, , "x8"
        TreeView1.nodes.Add , , "root1", "B Symbols"
        TreeView1.nodes.Add "root1", tvwChild, , "y1"
        TreeView1.nodes.Add "root1", tvwChild, , "y2"
        TreeView1.nodes.Add "root1", tvwChild, , "y3"
        TreeView1.nodes.Add "root1", tvwChild, , "y4"
        TreeView1.nodes.Add , , "root2", "C Symbol"
    End Sub

  2. #2
    Join Date
    Jun 2005
    Location
    Orissa
    Posts
    150

    Re: TreeView Problems - Expand All TreeNodes and +/- Not Displaying

    check the LineStyle in the properties, and make it to "tvwRootLines", which will view u the +/- signs...

  3. #3
    Join Date
    Jun 2006
    Posts
    194

    Re: TreeView Problems - Expand All TreeNodes and +/- Not Displaying

    Thank you VB_Learner, that did the trick.

    Still need to know how to have all the nodes expanded when the form first loads though.

    Thanks

  4. #4
    Join Date
    Jun 2005
    Location
    Orissa
    Posts
    150

    Re: TreeView Problems - Expand All TreeNodes and +/- Not Displaying

    add the following code after the code in the form load to expand...

    'add to expand the parent nodes
    TreeView1.Nodes.Item("root").Expanded = True
    TreeView1.Nodes.Item("root1").Expanded = True
    TreeView1.Nodes.Item("root2").Expanded = True


    you can do it using the for loop, instead writing a new line for each parent node and u can check, if the parent node having a child node, if it has and it's a parent node, then expand, else, don't expand. use this code...treeview1.nodes("Index").parents...

    hope, this will help u...

    regards
    Deepak

  5. #5
    Join Date
    Jun 2006
    Posts
    194

    Smile Re: TreeView Problems - Expand All TreeNodes and +/- Not Displaying

    Wonderful...thank you, worked perfectly!

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)