• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 361
  • Last Modified:

Tree View in VB6

I need the code to view data in a database in the tree format, Kindly help
0
Ravi_Aces
Asked:
Ravi_Aces
1 Solution
 
kouroshparsaCommented:
Step1: Add a TreeView control to you form.
Step2: In the load method of the form, add the data to the TreeView
Example:
'TreeView1 is the name of the TreeView:

Private Sub Form_Load()
Dim i As Integer
Dim factory As Node
Dim group As Node
Dim person As Node

    ' Create some nodes.
    Set factory =TreeView1.Nodes.Add(, , "f R & D", "R & D")
    Set group = TreeView1.Nodes.Add(factory, tvwChild, "g Engineering", "Engineering")
    Set person = TreeView1.Nodes.Add(group, tvwChild, "p Cameron, Charlie", "Cameron, Charlie")
    Set person = TreeView1.Nodes.Add(group, tvwChild, "p Davos, Debbie", "Davos, Debbie")
    person.EnsureVisible
    Set group = TreeView1.Nodes.Add(factory, tvwChild, "g Test", "Test")
    Set person = TreeView1.Nodes.Add(group, tvwChild, "p Able, Andy", "Andy, Able")
    Set person = TreeView1.Nodes.Add(group, tvwChild, "p Baker, Betty", "Baker, Betty")
    person.EnsureVisible
   
    Set factory = TreeView1.Nodes.Add(, , "f Sales & Support", "Sales & Support")
    Set group = TreeView1.Nodes.Add(factory, tvwChild, "g Showroom Sales", "Showroom Sales")
    Set person = TreeView1.Nodes.Add(group, tvwChild, "p Gaines, Gina", "Gaines, Gina")
    person.EnsureVisible
    Set group = TreeView1.Nodes.Add(factory, tvwChild, "g Field Service", "Field Service")
    Set person = TreeView1.Nodes.Add(group, tvwChild, "p Helms, Harry", "Helms, Harry")
    Set person = TreeView1.Nodes.Add(group, tvwChild, "p Ives, Irma", "Ives, Irma")
    Set person = TreeView1.Nodes.Add(group, tvwChild, "p Jackson, Josh", "Jackson, Josh")
    person.EnsureVisible
    Set group = TreeView1.Nodes.Add(factory, tvwChild, "g Customer Support", "Customer Support")
    Set person = TreeView1.Nodes.Add(group, tvwChild, "p Klug, Karl", "Klug, Karl")
    Set person = TreeView1.Nodes.Add(group, tvwChild, "p Landau, Linda", "Landau, Linda")
    person.EnsureVisible


    TreeView1.Nodes(1).EnsureVisible
End Sub
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now