I’m working on a system and I’ve got a treeview which must contain the project structure
from objects.
This structure looks something like this:
Project
|- Module1
| |- Xml1
| | |- Element
| | |- Element
| | | |- Element
| | | |- Element
| | | | |- Element
| | | |
| | | |- Element
| | |
| | |- Element
| |
| |- Xml2
| |- Element
|
|- Module2
|- Xml1
|- Element
etc..
Now when i want to add an Xml file to a module it’s easy because i know it has
2 nodes above it. (project, module)
in c# :
public void AddXmlToTree(string xmlFile)
{
projectTreeView.Nodes[0].LastNode.Nodes.Add(xmlFile);
}
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.
Not tested at all, but can be used as direction :