?
Solved

Treeview query

Posted on 2001-08-20
2
Medium Priority
?
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
beercat2 earned 400 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

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!

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Suggested Courses

743 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