How can I make a dynamic treeview in c#?

shappyking

New Member
I'm working on a system and I've got a treeview which must contain the project structurefrom objects.This structure looks something like this:\[code\]Project |- Module1 | |- Xml1 | | |- Element | | |- Element | | | |- Element | | | |- Element | | | | |- Element | | | | | | | |- Element | | | | | |- Element | | | |- Xml2 | |- Element | |- Module2 |- Xml1 |- Element\[/code\]etc..Now when i want to add an Xml file to a module it's easy because i know it has2 nodes above it. (project, module)in c# : \[code\]public void AddXmlToTree(string xmlFile){ projectTreeView.Nodes[0].LastNode.Nodes.Add(xmlFile);}\[/code\]note: i'm using LastNode because i add them in order of the tree.Now the problem:Every element can have another element so it is basically limitless.I can't just make a million methods like that.I need something else for this maybe some recursive method.I think I need to get the Node of the last added Element object so I can add the next element node to this I just don't know how to get it.I hope you can understand my question.
 
Back
Top