Results 1 to 7 of 7

Thread: Another question about TreeViews...

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225
    Don't worry - this will probably be the last question from me about them. ;-)

    How do I go about closing all the nodes/threads in a TreeView which the user has just opened?

    I thought it would've been .Refresh but it didn't do it.

    -Git

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Oh no! I had to go to the Components window! (OH THE HORROR!)
    Don't worry: I'll get over it.
    Code:
    Private Sub Command1_Click()
        Dim Node As Node
        For Each Node In TheNameOfTheTreeviewControlOnTheFormInYourProjectGoesHere.Nodes
            Node.Expanded = False
        Next
    End Sub

  3. #3
    Guest
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
        Dim i As Long
        For i = 1 To TreeView1.Nodes.Count
            TreeView1.Nodes.Item(i).Expanded = False
        Next
    End Sub

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    Private Sub TreeView1_Expand(ByVal Node As MSComctlLib.Node) 
        Node.Expanded = False
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5
    Guest
    he wants them to be collapsed after a certain period of time or something like that(I think) I dont think he wants to disable expansion all together.

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Oh, i thought that was what he wanted with "which the user has just opened"
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Posts
    225
    I tried Yonatan's code and it worked straight off how I wanted. Thanks for all you guy's help - I think I've finally finished work on this TreeView... :-)

    Cyas.

    -Git

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