I have an array (tvw_Nodes) that I would now like to use to add to a treeview as the names of the nodes.
These nodes would be childnodes, and then I have a second array (tvw_ChildNodes) which would be the ... hmm... grandchild Nodes??
How do I go about taking the elements from the array and adding them to the treeview?
I tried something like this but I get the error "Index out of bounds":
vb Code:
With Treeview
For Ctr = 0 To Ubound(MyArray)
.Nodes(ctr).Text = MyArray(ctr)
Next
End With
This is all done in the Form_Load()
If somebody helps you, take time to RATE the post. I do.
"FAILURE IS NOT AN OPTION. It comes bundled with the software."
Below are some of the threads that have helped me along the way:
Before you can access a treeview node's property, the node has to exist or was already added to the treeview's nodes collection. Also, how do you intend to relate the grandchild nodes? Do they all fall under one child node?
but I am trying to get it so I load the node names from a database, then add the nodes required.
I am tring to do it this way, so in the future the user can add a node, that new node would be stored in the database, and then, the next time the app is run, it would have the new node as well.
I hope you can understand this.
If somebody helps you, take time to RATE the post. I do.
"FAILURE IS NOT AN OPTION. It comes bundled with the software."
Below are some of the threads that have helped me along the way:
The grandchild nodes fall under different childnodes.
I have tried this and now get "Element not found" EDIT This now works, or should I say goes through the code, but still doesn't show any new nodes on the treeview.
So, if I am storing the names of the nodes in a database, then I would have to sore this is another field, or in the same, but split the string when loaded into the array?
possibly a two dimentional array?
If somebody helps you, take time to RATE the post. I do.
"FAILURE IS NOT AN OPTION. It comes bundled with the software."
Below are some of the threads that have helped me along the way:
What are the fields in the database, and how are your retrieving the info from the database (eg. how come you ended up with an array instead of a recordset)
When storing (and your using the child relationship and the node has a parent), relative field = node.Parent.Index
Above implies that you will have to store/process your root level nodes differently (since they have no parents). For these nodes, store relative = 0 in DB. When setting up the treeview from recordset, if rs.Fields("relative").Value = 0 then leave that argument blank ...
What are the fields in the database, and how are your retrieving the info from the database (eg. how come you ended up with an array instead of a recordset)
This is an excellent question, and the answer is ......
I am only just starting out with databases, so I assumed I had to store the retrieved data frm the DB into an array to use afterwards.
I also have to learn how to set up my database as well.
If somebody helps you, take time to RATE the post. I do.
"FAILURE IS NOT AN OPTION. It comes bundled with the software."
Below are some of the threads that have helped me along the way: