Need to move this one more node

Troy

Well-known member
Joined
Feb 7, 2005
Messages
153
Programming Experience
10+
Ok guys I can't see the forest through the trees. *pun intented*
I need to move sModelNumber node under the associated Customer Node I created before. I'm allowing multiple products to be purchased from the same customer and would like the treeview to show not just their name but also in a sub branch below their name the products they've purchased which is in this case is houses and the Modelnumbers for them.

Right now the code places them in the same node level as the client name and I need to bounce it beneath the client name.

In bold is the code I've added that seems to need tweaking. Can you help I'm getting crosseyed.:eek:

Dim indx AsShort
Dim currentAlpha AsString
Dim sContactName AsString
Dim sModelNumber AsString

indx = Nothing
currentAlpha = Nothing
sContactName = Nothing
rowCustomer = Nothing
rowProducts = Nothing

'Populate Treeview Control



For indx = Asc("A") To Asc("Z")
currentAlpha = Chr(indx)
tvTreeView.Nodes.Add(New TreeNode(currentAlpha))
' Add a child TreeNode for each Author in the matching Main Node.
ForEach rowCustomer In dt.Rows
If (UCase(Mid(rowCustomer.Item("LastName1"), 1, 1)) = currentAlpha) Then
sContactName = rowCustomer.Item("LastName1") & ", " & rowCustomer.Item("FirstName1") & " " & rowCustomer.Item("MiddleInitial1") & "."
tvTreeView.Nodes(indx - 65).Nodes.Add(sContactName).Tag = rowCustomer.Item("ContactID")

ForEach rowProducts In dt2.Rows
sModelNumber = rowProducts.Item("ModelNumber")
tvTreeView.Nodes(indx - 65).Nodes.Add(sModelNumber).Tag = rowProducts.Item("ContactID")
Next



EndIf



Next



Next
 
Last edited:
..Nodes.Add is a function method, not a sub method. The return value is the instance of TreeNode that was added, you can catch this instance and use to add child nodes to it.
 
Back
Top