CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2000
    Location
    canada
    Posts
    60

    Expand and Collapse TreeView

    Hi,

    I need to know how cani programmatically expand or collapse a treeview.

    Thanks in advance

    "the opposition of the opposites is the engine of becoming"

  2. #2
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Expand and Collapse TreeView


    TreeView1.Nodes("NodeKey").Expanded = true
    ' or
    Treeview1.Nodes(3).Expanded = true



    You can not expand the entire treeview with one statement. You must expand individual nodes

    John G

  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Expand and Collapse TreeView

    'Just addidtion to the John's answer - how to switch between expand/collapse

    private Sub Command1_Click()
    With TreeView1
    .Nodes.Add , , "aaa", "aaa"
    .Nodes.Add "aaa", tvwChild, "bbb", "bbb"
    .Nodes("aaa").Expanded = true

    End With
    End Sub

    private Sub Command2_Click()
    TreeView1.Nodes("aaa").Expanded = Not TreeView1.Nodes("aaa").Expanded


    End Sub



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

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

Featured