Passing a TreeView control around

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to pass a TreeView control to a public global method to populate
the tree with data from the DB.

Here's the call I make from the Form Load:

Private Sub Form_Load()
'Load the tree according to information in the database
Call treeInit(Me.treeBranches, "SELECT parentId FROM Branches WHERE
parentId = ")
End Sub

Here's the function definition for treeInit():

Public Sub treeInit(ByRef tree As TreeView, qry As String)

treeBranches is the name of the TreeView control that I'm trying to pass
around, but I keep getting a "Type Mismatch" error when I run the code.

Inside of the treeInit method, I'm trying to recursively create the tree by
passing Node objects around (not TreeNodes). Is this allowed? How do I create
a brand new node to store the current value that the recursive call is
working on?

Thanks,

Andy
 
Hi Andy

The TreeView object is referenced by the Object property of the control, not
the control itself. So try this:

Call TreeInit(Me.treeBranches.Object, "Select...")
 
Back
Top