Does anybody know how to move a treenode under VB.Net. It used to be easy under VB6, you just changed the parent property.
I want to allow users to move nodes within a parent node i.e
will become :-
Any ideas gratefully appreciated :-(
ADAdministrator Syncfusion Team October 2, 2002 02:27 PM
I believe can you just adjust the position of the child nodes in the Parent's Nodes collection. Using say Remove and Insert, for example.
FRFruitBatInShadesOctober 3, 2002 03:38 AM
I've tried allsorts but the results are not reliable, you either get clones or the nodes end up appearing at the end!
Do you have a code example?
ADAdministrator Syncfusion Team October 3, 2002 07:12 AM
The Nodes collection does not have an InsertAt method, so you may just have to rebuild the collection in the order that you want things. To do so, you can save all the nodes, then clear the Nodes collection, and add the nodes back in the order that you want them. Here is some code.
private void button1_Click(object sender, System.EventArgs e)
//move treenode 3 to treenode 1
int targetIndex = 1;
int sourceIndex = 3;
TreeNode tn = treeView1.Nodes[sourceIndex];
TreeNode tnc = new TreeNode[treeView1.Nodes.Count];
int k = 0;
foreach(TreeNode t in treeView1.Nodes)
tnc[k++] = t;
for(int i = 0; i < k; i++)
if(i == targetIndex)