Saturn
Member
- Joined
- Jul 30, 2023
- Messages
- 8
- Programming Experience
- 1-3
I will try my best to explain this. I'm working on an app for Papyrus(namely Starfield's version of it), and my TreeView displays all my parent and child nodes correctly.
For example(indent wont work like I want for the lower part):
Actor Script
* Functions
* Events
I have 47 parent nodes, and that is the amount that treeView.Nodes.Count reports. I don't know if that's supposed to return all nodes, but whatever. I am trying to get around having to hardcode every single node just to add new nodes. This is my code for creating the 47 parent nodes:
Now I need to add the nodes for the categories "Functions" and "Events" as children to each of the parent nodes:
Here is where the strange thing begins. When I need to add a new node to a child node of a parent node, I get the classic ArgumentOutOfRange exception. Im thinking maybe Im just getting the structure wrong, treeviews can be confusing sometimes, so I did a little test with the first parent node:
For example(indent wont work like I want for the lower part):
Actor Script
* Functions
* Events
ActorBase Script* Functions
* Events
I have 47 parent nodes, and that is the amount that treeView.Nodes.Count reports. I don't know if that's supposed to return all nodes, but whatever. I am trying to get around having to hardcode every single node just to add new nodes. This is my code for creating the 47 parent nodes:
C#:
public static void CreateParentNodes(TreeView treeView)
{
for (int i = 0; i < ScriptObjects.Count; i++)
{
treeView.Nodes.Add(ScriptObjects[i], ScriptObjects[i]);
}
}
Now I need to add the nodes for the categories "Functions" and "Events" as children to each of the parent nodes:
C#:
private static void AddCategoriesToParentNodes(TreeView treeView)
{
for(int i = 0; i < treeView.Nodes.Count; i++)
{
for (int j = 0; j < Categories.Count; j++)
{
treeView.Nodes[i].Nodes.Add(Categories[j], Categories[j]);
}
}
}
Here is where the strange thing begins. When I need to add a new node to a child node of a parent node, I get the classic ArgumentOutOfRange exception. Im thinking maybe Im just getting the structure wrong, treeviews can be confusing sometimes, so I did a little test with the first parent node:
treeView.Node[0].Nodes.Count
this returned 0, despite there obviously being 2 children of this node. Why is happening?