Solved

Treeview query

Posted on 2001-08-20
2
183 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
ID: 6407738
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
ID: 6410800
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

896 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

13 Experts available now in Live!

Get 1:1 Help Now