Treeview Control

G

Guest

Where can I find good information on adding nodes nad childnodes to a
treeveiew. I'm trying to do the following:

IN THE TREEVIEW CONTROL

Event
--> Weightclass
---> Lightweight
Person
Person
Person
---> Middleweight
Person
Person

and so on.. Any ideas?

Thanks in adavnce..!!

Jim
 
J

Jeff Gaines

Where can I find good information on adding nodes nad childnodes to a
treeveiew. I'm trying to do the following:

IN THE TREEVIEW CONTROL

Event
--> Weightclass
---> Lightweight
Person
Person
Person
---> Middleweight
Person
Person

and so on.. Any ideas?

Thanks in adavnce..!!

Jim

The help file has an example of adding nodes programmatically, have you
read that?

Basically you create a node and add it to the TV control. The fun is in
reading you data in and being clear exactly where you want to add it,
it's easiest if you can do this in a loop:

Get your data
Create a node
add it to the TV
create the sub node
add the sub node to the node created above
etc.
until you have read all the data for the first main node
then go back and start again.
until you have read all your data

It's often better though to add just the first level nodes and only add
data to them when the user expands the TV, makes it quicker.

Put something together based on this then come back if you get stuck.
 
G

Guest

Jeff,

Thanks for the help..

I can get it to add a Main folder and go 1 sub folder deep. I can't get it
to go any further. I have no idea what I'm doing or what I'm doing wrong.

My TV looks like this:

Event
-->Male
-->Weightclass
-->Lightweight


It should be:

Event
-->Male
-->WeightClass
-->Lightweight
--> Person 1
--> Person 2
-->Middleweight
--> Person
-->Heavyweight
--> Person
-->Female
-->Weightclass
-->Lightweight
--> Person 1
--> Person 2
-->Middleweight
--> Person
-->Heavyweight
--> Person

Thanks again for your help.

Jim
 
J

Jeff Gaines

Jeff,

Thanks for the help..

I can get it to add a Main folder and go 1 sub folder deep. I can't
get it to go any further. I have no idea what I'm doing or what I'm
doing wrong.

My TV looks like this:

Event
-->Male
-->Weightclass
-->Lightweight


It should be:

Event
-->Male
-->WeightClass
-->Lightweight
--> Person 1
--> Person 2
-->Middleweight
--> Person
-->Heavyweight
--> Person
-->Female
-->Weightclass
-->Lightweight
--> Person 1
--> Person 2
-->Middleweight
--> Person
-->Heavyweight
--> Person

Thanks again for your help.

Jim

Jim

I would guess you are adding sub nodes to the wrong parent. You need:

// start event loop
tnEventNode = new TreeNode (event)
TreeView.Nodes[0].Add(tnEventNode)
//start gender loop
tnGenderNode = new Treenode(gender)
tnEventNode.Add(tnGenderNode)
//start weight loop
tnWeightClass = new TreeNode(WeightClass)
tnGenderNode.Add(tnWeightClass)
//start sub weight loop
tnLightWeight = new TreeNode(Lightweight)
tnWeightClass.Add(tnLightWeight)
//start people loop
tnPerson = new TreeNode(Person1)
tnWeightClass.Add(tnPerson )
//end people loop
//end sub weight loop
//end weight loop
//end gender loop
//end event loop

i.e. you add nodes to the parent in each case, it looks like you are
adding them all to the event node. You probably need to set up quite a
deeply nested loop, I've suggested where but it depends how your data
is set out in its original form.

It can get complicated when you have lots of categorised data - use
meaningful node names, it will help you to keep track.

My programming PC is off at the moment so I've done this from memory
but hopefully it will help you make some progress! Key thing is just to
make sure each category of data is added to the correct parent node.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top