Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TreeView Control 2

Status
Not open for further replies.

MartinF

Technical User
Sep 19, 2000
143
0
0
FR
Hi,

Can anyone explain to me how to use the ActiveX treeview form control, as i cannot seem to get it to do anything.

Also am i correct in assuming that it is for viewing folders and files like in windows explorer?

Thanks
 
I spent several Hours on this one myself. To help with the learning curve I did a search via google and found several docs to help me out.
but here it is in a nut shell
Place the treeview control on the form and name it treeview1
this code goes in the form load event
Private Sub Form_Load()
'first you have to add the parent
Treeview1.nodes.add , ,"Parentkey","Parent"
'Then add the child
Treeview1.nodes.add "Parentkey",tvwChild,"Childkey","Child"
'Now a child of the child
Treeview1.nodes.add "Childkey",tvwChild,"Child2key","Child2"
end sub
this is basically the "Hello World" version of the data tree and you will get into things like recursion and such but it is well worth the time to learn it as it is a very powerful feature. You will find it is much more then just for file and folders it is great where ever there is a hierarchy. I use it to show the buildings then the floors located in those buildings then the rooms located on the floor then the equipment located in the rooms then the parts for that equipment ect..
Good luck and hope this helps
 
Just a note about legal niceties. The TreeView control is not part of Access. The one provided with Visual Basic is not licensed for redistribution as part of an Access application. If you intend to distribute your application, you may be violating your license terms. Rick Sprague
 
Hi,

Thanks for responding guys,

RickSpr,
I have TreeView control installed on my Access Toolbox as part of the standard installation, so does this mean that i can distribute applications with it, or will i still be violating license terms.

Thanks
 
I'm pretty sure a TreeView control didn't come as part of my Office 97 or Office 2000 Developer Edition versions of Access. If yours was installed as part of Access, you probably have a license to redistribute it (check the help file for "redistributables" and "license" to be sure). But just being able to install it on the toolbar doesn't mean it's licensed for redistribution. Rick Sprague
 
Hi,

Well i've populated my treeview control, but how do i return a value from it to perform other actions?

Cheers
 
Hi Braindead2

What is the best point to call value from the TreeView, i got it to output in the debug window from the form timer, but if i tried to insert the line into any of the controls event procuedures i just got an error message saying that the object variable was not set.

Thanks
 
Since I'm not sure what you are attempting to do it is hard to say what the best point is.
Try this example

Private Sub treeview1_DblClick()
dim Retstr as string
retstr = me!treeview1.Object.Selecteditem
msgbox (retstr)
end sub

you can use several of the objects events to do just about anything.
I suggest you do a search on treeview and you will find many fine examples. I spent several days before I felt like I had mastered it.
 
Thanks BrainDead2,

Thats just about what i wanted, i didn't know you could use the same call events as on a normal control, because they arent listed in the properties box.

Cheers
 
good lord guys! I've spent three days on treeview!

Should'a come here first!!!

thanks for the help

"It doesn't matter how idiot-proof you make it, someone makes a better idiot!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top