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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code: Treeview Control

Status
Not open for further replies.

tek2002

Programmer
Aug 21, 2001
67
US
I have 2 treeviews: treeAvailableTable and treeSelectedTable

During From Load, treeAvailableTable is being populated with table names and columns for each table from a
SQL Database...this works perfect.

Problem:
For the 'Add All' procedure, i would like for a user to
click on a table in treeAvailableTable treeview and then hit the ADD ALL button which will add the table name as parent and the columns as children to the treeSelectedTable treeview. Whats happening is this:

treeAvailableTable

+Months
-code
-month
+State
-state_code
-state_name

if i highlight Months and hit 'ADD ALL' this is what
SelectedTable treeview looks like:

treeSelectedTable

-Months
-code
-month

if i then highlight State and hit 'ADD ALL' this is what treeSelectedTable treeview looks like:

treeSelectedTable

-State
-code
-month
-
-state_code
-state_name

I would like treeSelectedTable treeview to look exactly like
treeAvailableTable...What am i doing wrong...see code below
Thanks in advance
Annie

------------------------CODE------------------------------
Private Sub cmdAddAll_Click()
Dim ChildCount
Dim nodItem As Node
Dim newNode2 As Node

MoveAvailableToSelected

ChildCount = (treeAvailableTables.SelectedItem.Children)


treeSelectedTables.Nodes.Add.Root = (treeAvailableTables.SelectedItem)
Set nodItem = treeAvailableTables.SelectedItem.Child

If treeAvailableTables.SelectedItem.Children > 0 Then
MsgBox "there are children: " & ChildCount


'Check for children nodes.

'Get first child node.

Do
treeSelectedTables.Nodes.Add = nodItem
If nodItem = nodItem.LastSibling Then
'This is the last node.
Exit Do
Else
'Get the next node.
Set nodItem = nodItem.Next
MsgBox nodItem
End If
Loop
End If



End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top