TreeViewStack
Hello everybody,
in VB6 filling a TreeView with data is a mess because there is no stack-class.
thanks to Jabaco and the Java-framework we already have a stack class that can be found in the namespace java#util.
I have created a small class that makes life easy, with it you can fill a TreeView very convenient, and your code looks almost very similar to the tree you want to create.
class: TreeViewStack; extends: java#util#Stack
A natural tree exists of root, limbs, nodes between limbs, and leafs - just like the TreeViewStack-class does have
Also have a look at the small Jabaco-example attached.
Jabaco makes fun!
OlimilO
in VB6 filling a TreeView with data is a mess because there is no stack-class.
thanks to Jabaco and the Java-framework we already have a stack class that can be found in the namespace java#util.
I have created a small class that makes life easy, with it you can fill a TreeView very convenient, and your code looks almost very similar to the tree you want to create.
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Private Sub FillTree With TVS For i = i To i + 3 .AddNode("Person " & CStr(i) & " (Pre, Sur)", "Person" & CStr(i)) .AddNode("Address", "Address" & CStr(i)) .AddLeaf("Sreet (Name, Nr)", "Sreet" & CStr(i)) .AddLeaf("City (PLZ/Zip, Name)", "City" & CStr(i)) .pop .AddNode("Phone", "Phone" & CStr(i)) .AddLeaf("Private (country, city, nr)", "PhonePrivate" & CStr(i)) .AddLeaf("Business (country, city, nr)", "PhoneBusiness" & CStr(i)) .AddLeaf("Mobile (country, net, nr)", "PhoneMobile" & CStr(i)) .pop .pop Next .Root.Expand = True End With End Sub |
class: TreeViewStack; extends: java#util#Stack
|
|
Jabaco Source |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
Option Explicit Dim myRoot As Node Dim myTree As TreeView Public Sub TreeViewStack(aTree As TreeView) myTree = aTree End Sub Public Function AddNode(Text As String, Key As String) As Node AddNode = Cast(Base.push(AddLeaf(Text, Key)), Node) End Function Public Function AddLeaf(Text As String, Key As String) As Node If myRoot = Nothing Then Call Root Dim rnd As Node = Me.peek AddLeaf = myTree.Nodes.Add(rnd, tvwChild, Key, Text) End Function Public Function Root() As Node If myRoot = Nothing Then myRoot = Cast(Base.push(myTree.Nodes.Add(Nothing, tvwFirst, "Root", "")), Node) End If Root = myRoot End Function Public Function peek() As Node peek = Cast(Base.peek, Node) End Function Public Function pop() As Node pop = Cast(Base.pop, Node) End Function |
A natural tree exists of root, limbs, nodes between limbs, and leafs - just like the TreeViewStack-class does have
Also have a look at the small Jabaco-example attached. Jabaco makes fun!
OlimilO
This post has been edited 1 times, last edit by "OlimilO" (Sep 19th 2009, 6:03pm)
