$99 VS $1000+. UI Control for ASP.NET AJAX(contains chart and gridview).
Windows Forms KetticTreeView Control
Build complex navigation systems and display complex hierarchical structures
Home > WinForms UI Controls > User Manual > Reorder Nodes for TreeView in C#

Reordering Nodes of KetticTreeView in C#.NET

KetticTreeView control for WinForms is capable of reordering nodes at runtime. The tree view interface designers can easily drag and drop to reorder the nodes. However, the developer cannot manipulate the node directly and the users of their application can reorder directly. Additionally, the developers can also customize the KetticTreeView nodes reordering in C# code for .NET application.

C# Reordering Nodes of KetticTreeView

KetticTreeView provides the Insert() method and Add() method within the Nodes collection for developers to reorder node in C#. The C# code below shows how to reorder nodes by using the Add() method.

KetticTreeNode parentNode1 = new KetticTreeNode("First Parent");
KetticTreeNode parentNode2 = new KetticTreeNode("Second Parent");

this.ketticTreeView1.Nodes.Add(parentNode1);
this.ketticTreeView1.Nodes.Add(parentNode2);

KetticTreeNode childNode = new KetticTreeNode("Child Node");

parentNode1.Nodes.Add(childNode);

parent nodes collection
parentNode1.Nodes.Remove(childNode);
parentNode2.Nodes.Add(childNode);
Moreover, the Insert() method within the Nodes collection can move a node into a collection of multiple nodes and reset the position of a node. It uses the parameters as the index to place the node and a reference to insert the node. The following C# code demonstrates how to change the position of a node using the Insert() method.

KetticTreeNode parentNode1 = new KetticTreeNode("First Parent");
KetticTreeNode parentNode2 = new KetticTreeNode("Second Parent");

this.ketticTreeView1.Nodes.Add(parentNode1);
this.ketticTreeView1.Nodes.Add(parentNode2);

KetticTreeNode childNode = new KetticTreeNode("Child Node");
KetticTreeNode childNode2 = new KetticTreeNode("Child Node2");
KetticTreeNode childNode3 = new KetticTreeNode("Child Node3");

parentNode1.Nodes.Add(childNode);
parentNode2.Nodes.Add(childNode2);
parentNode2.Nodes.Add(childNode3);

parentNode2.Nodes.Insert(1, childNode);

UI Controlsfor Windows Forms
.NET WinForms UI Overview.NET WinForms UI Features.NET WinForms UI GuideC# WinForms UI DesignVB.NET WinForms UI Design
WinForms UI Controls