Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview Control

Status
Not open for further replies.

maxxev

Technical User
Jul 17, 2008
139
NL
Need some help with this please.

I have a query formed of 2 queries:
"QComponent_Ings Query Query"
I would like to make a treeview from this query and it contains everything I want as below:

My "master" ID:
Table name: "tblIng_Spec_Detail"
Unique: "Ing_SpecID"
Other fields: "Supplier Ing Name"


Table linking to the above
Table Name: "tblComponent_Ings"
Unique: "Ing_Comp_Reg_ID"
Links: "Ing_SpecID" to "Ing_SpecID" of above table
Other field:"%", "Ing_Sub_Component_ID"


Table linking to the above
Table Name: "tblSubComponents_in_Components"
Unique: "SubComp_in_ingID"
Links: "Ing_Comp_Reg_ID" to "Ing_Comp_Reg_ID" of above table
Other field:"%", "Ing_Sub_Component_ID"

BOTH of the above tables have a link to another via the ID "Ing_Sub_Component_ID" which gives details on the standard components.
table Name: "tblSub_Component_Ings"
Unique: "Ing_Sub_Component_ID"
Other fields: "Ingredient" & "Further info"


So I would like to build a tree like this:

1."Ing_SpecID" (showing the field "Supplier Ing Name")

2."Ing_Comp_Reg_ID" (showing "Ingredient",pulled through from "Ing_Sub_Component_ID" link to "tblSub_Component_Ings" and also "%")

3."SubComp_in_ingID" (showing "Ingredient",pulled through from "Ing_Sub_Component_ID" link to "tblSub_Component_Ings" and also "%")


Cheers for ANY help in working out how to use the treeview, I have seen quite a few online but I have failed to wrap my head around it :(
 
Maxxev,

It's difficult to explain the whole thing in a short answer. I'll try to give you a start.

Basically, you need to loop through the records in your tables, calling the treeview's nones.add() method for each one that you want to add to the tree.

This method takes the following parameters:

- The key of the related noded (see example below).

- The relationship between the new node and the related node (see below).

- Any unique string that will identify the node you are adding. (It could be a combination of the table name and the record's primary key, for instance.)

- The actual text that you want to display.

- Two images that you want to appear (I suggest you ignore these to begin with).

To add nodes at the hightest level, omit the first param, and set the second one to 1. So the following code (in the treeview's Init) will create a single level tree, with four items:

this.nodes.add( , 1, "A1", "East")
this.nodes.add( , 1, "A2", "North")
this.nodes.add( , 1, "A3", "West")
this.nodes.add( , 1, "A4", "South")

And this will add nodes below the "East" node:

this.nodes.add("A1", 4, "B1", "Poland")
this.nodes.Add("A1", 4, "B2", "Slovakia")
this.nodes.add("A1", 4, "B3", "Germany")

and to go one more level down, below Germany:

this.nodes.add("B3", 4, "C1", "Barvaria")

Do you see the pattern? To add a top-level node, pass 1 in the second param and leave the first param empty. The third param is the unique ID (I made up A1, B1, etc.)

To create a child node, pass the unique ID of the parent node in the first param. The 4 in the second param means it's a child.

I know it sounds a bit complicated, but why don't you try this out, and come back with more questions once you've made a start.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Sorry what do you mean by the treeview's int?

Please be aware that i'm a complete dunse when it comes to code, everything i've done is via copy and paste, or creating a similar button (for instance) and stealing the bits I need...

Thank you.
 
Maxxev,

May I be honest? If you don't know what the Init method of a class is, you need to learn some of the very basic concepts before you tackle the more advanced things like treeviews.

The Init method of a control (all controls have them, not just treeviews) is a place to put code that is executed when the control is instantiated (when it "comes to life", if you like). In this case, you need the code I showed you to execute when the treeview first appears, which is why I suggested putting it in the Init.

To understand it better, you need to read up on the whole concept of events and methods. These are fundamental to doing any kind of modern Windows programming, including in VFP.

I hope you don't mind me pointing this out to you. It's really just a question of learning the basics before you tackle the more difficult stuff.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
I don't mind at all, I know I cannot program for rubbish, however I'm one of only 2 people at the company who knows anything aobut databases and the other never has time.

I'm more of an analysist sort of person (my job role BTW is admin, i'm just fed up of spreadsheets).
I have designed the table structure for the database (roughly 100 tables...).

I had previously tried to get something going but failed, but was pointed out that starting small, getting something working then combining was a more sensible way of trying to do things.

So with that pointer, using the GUI interface and some help from this forum I have completed an ingredient and contact database (20/100 of the tables) that does everything we need SO much better than the spreadsheets we have at the moment.

If I can get the other sections of the database working and then combine them as I want then we will have a company-wide database that does everything we want at the touch of a few buttons (the whole point of a database).

Anyway I ramble, what i'm saying is I no i'm not a programmer, I did not complete the Java or JS units of my HND however I aced the systems analysis and database design sections.... lol.

Long ramble short.
I just want to create a user friendly view for the components within an ingredient, but I think the treeview has me beat this time.
I'll try and get the other fella (who can program) to take a look, if not then perhaps when I get the 2 modules I have finished we can get an outside contractor to do the coding!

Cheers for the help anyway.
 
Maxxev,

Based on what you've said, you've done pretty well to do as much as you've done. I was a bit worried that my remarks might have sounded a bit disparaging, but I'm pleased you didn't take them that way.

Good luck with your endeavours. If and when you feel ready to tackle the treeview again, do come back with some questions.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Nope, no books.

Thank you for the suggestion i'll take a look.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top