Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / October 2004

Tip: Looking for answers? Try searching our database.

Treeview Control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jcb1269 - 27 Oct 2004 21:21 GMT
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
Jeff Gaines - 27 Oct 2004 22:57 GMT
> Where can I find good information on adding nodes nad childnodes to a
> treeveiew. I'm trying to do the following:
[quoted text clipped - 16 lines]
>
> 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.

Signature

Jeff Gaines Damerham Hampshire UK

jcb1269 - 28 Oct 2004 21:18 GMT
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
 

> > Where can I find good information on adding nodes nad childnodes to a
> > treeveiew. I'm trying to do the following:
[quoted text clipped - 38 lines]
>
> Put something together based on this then come back if you get stuck.
Jeff Gaines - 28 Oct 2004 22:29 GMT
> Jeff,
>
[quoted text clipped - 37 lines]
>
> 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.

Signature

Jeff Gaines Damerham Hampshire UK


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.