Treeview

G

Guest

Hello.
I have a form with a treeview control.
I'd like to create an Expand/Collapse all button.
How can i do this?

Thanks

Luis
 
A

Alex Dybenko

Hi,
something like this

Sub ExpandCollapse(fOption as Boolean)
dim n as node

for each n in oTV.Nodes
n.expanded=fOption
next n

end sub

oTV - is a reference to your treeview control object

run this proc as ExpandCollapse True or ExpandCollapse False
 
D

David C. Holley

You can also selectively expand/collapse based on the .Key or .Tag
property - assuming that you've set them - by adding an if...then such as

For each n in oTv.Nodes
if n.tag = "CompanyDepartment" then n.expanded = fOption
next n

Assuming that you're tree looks something like this

-Accounting
-John Smith
-Mary Smith
-Human Resources
-John Willis
-Greg Gillis
-Purchasing
-April Brown
-June Bug
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Treeview rebuild 1
Rebuilding Treeview 1
Find in treeview 1
Treeview Control 3
Treenodes clear 1
Treeview Control 2
identifying clicked node 7
Stop Treeview startlabeldit 1

Top