Building a relationship tree in vb

Posted on 2009-02-20
Last Modified: 2013-12-25

I am developing a windows application in VB,  In which i store all the contact information, it is like an address book. I have to take the information about the relation ship between the person(whose information is being stored) and himself... Like whether he is a superior  or a subordinate or just an employee... Now based on this information, i need to build a 2D tree view which shows his superiors above him and subordinates below him. Now, how can i build this tree??? It has to take the information from the database and display the tree..
Please advise...

Question by:Priyadarshni
    LVL 76

    Expert Comment

    I have done that for family relationships with a Treeview control. However, the hierarchy goes across the page instead of down the page, so that might not suit you.

    Author Comment

    Ya... I do need a top down tree... But will i be able to modify your code to suit my requirements?
    LVL 76

    Accepted Solution

    Possibly, but it is rather specialised. In principle it is recursive search. This is some pseudocode.

    Usage is: Call TopBossID, 1

    Sub GetReportees(MemberID, Level)
        sgl = select * from mytable where BossID= MemberID sql
        do until rs.eof
               AddToTree Member, Level
               GetReportees MemberID, Level+1
    end sub

    Author Comment

    i am taking the data from the database and then checking the relation. Based on that relation i need to buid a tree...can i use recursion here?

    Author Closing Comment

    I was able to use recursive tree

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now