treeview, collapse ALL, expand ALL

Posted on 2001-06-29
Medium Priority
Last Modified: 2012-06-22

i populuate my treeview from a db on form_load.

i want to give my users to expand all parent/child/sibling branches or collapse all.

by default, when the form loads, i coded a few fixed branches to be expanded, but the child branches are all collapsed by default.

an example would be great.
Question by:jas777
  • 2
LVL 20

Expert Comment

ID: 6239383
To expand all use the following

Dim a
For a = 1 To TreeView1.Nodes.Count
Next a
LVL 20

Accepted Solution

hes earned 400 total points
ID: 6239449
To collapse all use this

Dim a

For a = 1 To TreeView1.Nodes.Count
   If TreeView1.Nodes(a).Expanded Then
          TreeView1.Nodes(a).Expanded = False
       End If
Next a

If you don't want it to collapse all the way back to the parent but you want theparent an it's children showing use

For a = 2 To TreeView1.Nodes.Count


Author Comment

ID: 6239516
thanks man,

i could of sworn i tried something to that effect last night, but it didn't work then.

thanks for the code, you rule...

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As a person who answers a lot of questions, I often see code that could be simplified, made easier to read, and perhaps most importantly made easier to maintain if the code was modified to use the Select Case statement. This article explains how to…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question