Generate tree nodes
1 answer
Here is some pseudo code that might help you get started
AddChildNodes(TreeNode parentNode)
{
var childNodeIds GetChildNodeIds(parentNode.Id);
foreach (int childNodeId in childNodeIds)
{
TreeNode childNode = new TreeNode();
//set other properties...
//add to parent
parentNode.Nodes.Add(childNode);
//call same function recursively
AddChildNodes(childNode);
}
}
Then, in your program, you get all the elements without the parent node id (root nodes) by creating a node for them and then calling the recursive function above.
+3
source to share