Treeview

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
Back
Top