Current filter:
                                You should refresh the page.

                                TreeList allows users to reorder nodes by dragging them with the mouse. If a node was moved from one parent to another, its position will be saved automatically, because it depends on the ParentID column value which is stored in the database. However, when nodes are reordered within the child collection, their position will be reset after the application is closed and opened again, or after reloading data.

                                To keep nodes positions, it is necessary to add additional column to the datasource to store the node index. In this situation, nodes positions can be restored after loading the data into the TreeList. This task can be accomplished by iterating all the nodes and updating the node index via the TreeList.SetNodeIndex method.

                                [C#]
                                void UpdateNodesPositions(TreeListNodes nodes) { List<TreeListNode> ns = new List<TreeListNode>(); foreach (TreeListNode n in nodes) ns.Add(n); foreach (TreeListNode n in ns) { UpdateNodesPositions(n.Nodes); n.TreeList.SetNodeIndex(n, Convert.ToInt32(n.GetValue("Order"))); } }
                                [VB.NET]
                                Private Sub UpdateNodesPositions(ByVal nodes As TreeListNodes) Dim ns As New List(Of TreeListNode)() For Each n As TreeListNode In nodes ns.Add(n) Next n For Each n As TreeListNode In ns UpdateNodesPositions(n.Nodes) n.TreeList.SetNodeIndex(n, Convert.ToInt32(n.GetValue("Order"))) Next n End Sub

                                 
                                Note that the UpdateNodesPositions method should be called after TreeList is populated with data.  It's also necessary to handle the AfterDragNode event and update the "Order" field's values as follows:

                                [C#]
                                private void treeList1_AfterDragNode(object sender, AfterDragNodeEventArgs e) { SaveNewRecordPosition(e); } private void SaveNewRecordPosition(NodeEventArgs e) { var nodes = e.Node.ParentNode == null ? e.Node.TreeList.Nodes : e.Node.ParentNode.Nodes; for(var i = 0; i < nodes.Count; i++) { nodes[i].SetValue(colSort, i); } }
                                [VB.NET]
                                Private Sub treeList_AfterDragNode(ByVal sender As Object, ByVal e As AfterDragNodeEventArgs) Handles treeList1.AfterDragNode SaveNewRecordPosition(e) End Sub Private Sub SaveNewRecordPosition(ByVal e As NodeEventArgs) Dim nodes = If(e.Node.ParentNode Is Nothing, e.Node.TreeList.Nodes, e.Node.ParentNode.Nodes) For i = 0 To nodes.Count - 1 nodes(i).SetValue(colSort, i) Next i End Sub