Solved

Treeview query

Posted on 2001-08-20
2
182 Views
Last Modified: 2012-05-07
Basically I want to use a treeview, but have never used one.  Yes I know you are asking what I have been doing all this time, but most of the the time I write server side code and not UI.  Anyways back to the point in hand......

I want to populate a tree view from the following table:

ID - primary key autonumber
Desc - eg. Liverpool V Man Utd (this is the field in the tree)
Parent ID - This will link back to the ID in a one to many / parent child type format.  Eg the example for desc will always be the parent, but a child could be robbie fowler to score the first goal etc etc.  Basically if you havent guessed, it is for a betting system.

So......if I have my table populated with all these parents and childs, then what properties do I have to use to get the tree looking somthing like:

Football
   Liverpool V Man Utd
      child info
      ........
   Another match
      .........
      .........
   Chelsea to win the league
Horse Racing
   Doncaster
      3.15pm
         Red Rum to win

etc etc

Cheers,

Ray.
etc etc


Also this is only a prototype, so the table design can be changed if you feel it necessary to answer my question.  If you have done something similar, but used a different table design then Im open to offers, as I just want the system up and running asap, and everything I am doing is flexible.
0
Comment
Question by:raybetts
2 Comments
 
LVL 1

Accepted Solution

by:
beercat2 earned 100 total points
Comment Utility
When you add a node to a TreeView, you need to set these properties:  an image (contained within an ImageList control), a key (a unique identifier for that node within the tree) and a label (what you want to see in the tree view).

The syntax for adding a node is as follows:
treeviewobject.Nodes.Add ([relative],[relationship],[key],[text],[image],[selected image]

So, if you were adding a parent object, such as "Liverpool V Man", you might say:
treeviewobject.Nodes.Add ,,1,"Liverpool V Man",image1

When adding a child, such as "Robbie Fowler to Score the First Goal", you might say:
treeviewobject.Nodes.Add "Liverpool V Man",tvwChild,2,"Robbie Fowler to Score the First Goal,image1

Obviously, you would probably want to use a recordset to dynamically fill the node text and key using data straight from the database rather than hardcode it.

This is the first time I've answered any questions, so bear with my attempt to explain this  :)  If you have any questions, let me know and I'll try to help out!

Brian
0
 
LVL 1

Author Comment

by:raybetts
Comment Utility
Brian

I had figured it out today at work on how the treeview works (sometimes Im lazy and hate brick walls - hence the question) .  But seeing as your answer was to a high standard and its your first time then I will give you the points.

I also managed to fill the treeview from a rs using a little recursion, so again you were on the right track.

Keep up the good work.

Ray.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

772 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

12 Experts available now in Live!

Get 1:1 Help Now