Mumbles0, thanks!
What next?
What next?
|Horse Racing
|GB
|Aintree Specials
|Kemp 25th Mar
|Ling 25th Mar
|IRE
|Punchestown Specials
|Steward's Enquiry
|Horse Racing
|\GB\Aintree Specials\Top Jockey
|\GB\Kemp 25th Mar\1m Mdn Stks
|\GB\Kemp 25th Mar\To Be Placed
|Horce Racing
|GB
|Aintree Specials
|Top Jockey
|GB
|Kemp 25th Mar
|1m Mdn Stks
|GB
|Kemp 25th Mar
|To Be Placed
Friend Sub PopulateTreeView(ByVal AllMarkets As UnpackAllMarkets, ByVal TreeView As TreeView)
Dim Ids, Names As String(), Nodes As TreeNodeCollection
TreeView.Nodes.Clear() 'Start afresh
With AllMarkets
For i = 0 To .MarketData.Length - 1 'For each market
With .MarketData(i)
Ids = .EventHeirachy.Split("/") 'Array of Ids
Names = .MenuPath.Split("\") 'Array of names
Nodes = TreeView.Nodes 'Initial collection of child nodes
For j = 1 To UBound(Ids) 'For each event list item
If Not Nodes.ContainsKey(Ids(j)) Then
Dim Node As New TreeNode 'Add a new node if it doesn't exist
Node.Text = If(j <= UBound(Names), Names(j), .MarketName)
Node.Name = Ids(j) 'This is the key
Nodes.Add(Node)
End If
Nodes = Nodes(Ids(j)).Nodes 'Next level down
Next
End With
Next
End With
End Sub
Dim AllMarkets As New UnpackAllMarkets(.marketData) PopulateTreeView(AllMarkets, tvMarkets) '<<< Add this With AllMarkets .....
Private Sub tvMarkets_AfterSelect(ByVal sender As Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvMarkets.AfterSelect
If e.Node.Nodes.Count = 0 Then
Beep()
Dim marketId As Integer = Val(e.Node.Name) 'This is the selected marketId
End If
End Sub



With .eventTypeItems(i)
'Dim AllEvents As New UnpackAllMarkets(.marketData)
'PopulateTreeView(AllMarkets, tvMarkets)
[B]tvMarkets.Nodes.Add(.id, .name())[/B]
Print(.name & " (" & .id & ")")
End With
Comment