Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I change the order of treenodes

Tags:

c#

I would like to change the order of System.Windows.Forms.TreeNodes on the same level.

any suggestions on how this might be done in .net-2.0.

like image 394
Brad Avatar asked Jun 01 '11 14:06

Brad


1 Answers

You need to manipulate the TreeView's Nodes collection. See TreeNodeCollection.

If you have three tree nodes and you want to move the last one to the front, for example: (Note: not tested code, but shows the idea)

var lastNode = MyTreeView.Nodes[2];
MyTreeView.Nodes.Remove(lastNode);
MyTreeView.Nodes.Insert(0, lastNode);
like image 102
Jim Mischel Avatar answered Oct 27 '22 00:10

Jim Mischel