Populating the Treeview Control

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