Solved

Tree View in VB6

Posted on 2004-08-17
3
323 Views
Last Modified: 2010-04-17
I need the code to view data in a database in the tree format, Kindly help
0
Comment
Question by:Ravi_Aces
3 Comments
 
LVL 2

Accepted Solution

by:
kouroshparsa earned 250 total points
ID: 11825161
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
groupNoAdj 7 115
incorrect syntax near the order by 10 56
storing csv file in table variable in Python 2 58
Java array 10 55
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question