Populating the Treeview Control

J

JamesJ

I want to start working with the treeview control but have
no idea where to begin. I would like to populate a treeview
with data from 2 table but have no idea on the code and where
to call the code from and how to trigger a function when
a node is selected. Would be nice to have something
similar to explorer-type interface. I'm hoping someone can
point me to an example.
As an example I have a movie table linked to a 'movietype'
table via a one-to-many relationship. Ideally, I would like to
have the movie titles displayed in the right pane and all movie
types displayed under the 'All Movies' node in the treeview.
Any help will be appreciated.

Thanks,
James
 
J

JamesJ

Can you point me to another, I still don't get it.
The article says that the Treeview is filled with
treTreeviewFill routine but I can't find anything
in the article that claims to be the treTreeviewFill routine.

James
 
D

Douglas J. Steele

Looks as though Doug didn't actually include the code in the article,
expecting the readers to download the database that accompanied it.
Unfortunately, Microsoft doesn't link to the downloadable databases in
situations like this, so you may be out of luck wrt to getting that code
sample.

See whether
http://msdn.microsoft.com/library/en-us/vbcon98/html/vbconusingtreeviewcontrol.asp
and
http://msdn.microsoft.com/library/en-us/vbcon98/html/vbconscenarioviewingbibliomdbdatabaseastree.asp
makes sense to you.

Since you can't bind a treeview to a recordset, the code for Access and VB
is going to be essentially the same.

Another example at MSDN includes a snippet:

Private Sub Form_Load()
TreeView1.Style = tvwTreelinesPlusMinusText ' Style 6.
Dim nodX As Node
Set nodX = TreeView1.Nodes.Add(,,"DV","Da Vinci")
Set nodX = TreeView1.Nodes.Add("DV",tvwChild,"T","Titian")
Set nodX = TreeView1.Nodes.Add("T",tvwChild,"R","Rembrandt")
Set nodX = TreeView1.Nodes.Add("R",tvwChild,,"Goya")
Set nodX = TreeView1.Nodes.Add("R",tvwChild,,"David")
nodX.EnsureVisible ' Show all nodes.
End Sub

Here, the root node, Da Vinci, is given a key of DV. A node Titian, with a
key of T, will be a child under that (identifiable because the first
argument in the Add method refers to the key of the parent). Another node
Rembrandt will be a child of Titian. Finally, two nodes Goya and David will
be children of Rembrandt.
 

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 ActiveX control 1
treeview control issue 1
Treeview Control (v6.0) MSCtrlLib 4
Treeview 4
Passing a TreeView control around 1
treeview flicker (goes blank) 1
Treeview code 0
Need help with a treeview 0

Top