Reply to thread

HI,



my code example.


private void Form1_Load(object sender, EventArgs e)

        {

            treeView1.AllowDrop = true; 

            treeView1.ExpandAll();

        }


        private void treeView1_ItemDrag(object sender, ItemDragEventArgs e)

        {

            DoDragDrop(e.Item, DragDropEffects.Move);

        }


        private void treeView1_DragEnter(object sender, DragEventArgs e)

        {

            e.Effect = DragDropEffects.Move;

        }


        private void treeView1_DragDrop(object sender, DragEventArgs e)

        {

            // Retrieve the client coordinates of the drop location.

            Point targetPoint = treeView1.PointToClient(new Point(e.X, e.Y));


            // Retrieve the node at the drop location.

            TreeNode targetNode = treeView1.GetNodeAt(targetPoint).Parent;


            // Retrieve the node that was dragged.

            TreeNode draggedNode = (TreeNode)e.Data.GetData(typeof(TreeNode));


            // Confirm that the node at the drop location is not

            // the dragged node and that target node isn't null

            // (for example if you drag outside the control)

            if (!draggedNode.Equals(targetNode) && targetNode != null)

            {

                // Remove the node from its current

                // location and add it to the node at the drop location.

                draggedNode.Remove();

                targetNode.Nodes.Add(draggedNode);


                // Expand the node at the location

                // to show the dropped node.

                targetNode.Expand();

            }

        }


see the screen shot


[ATTACH=full]57466[/ATTACH]




1) a problem i faced that i am not being able to reorder any node in same level. as a example Root1 has 3 nodes but when i try to reorder means up/down of any node in same level that is not getting possible. so please share code which allow Node to reorder means up/down of any node in same level.


so please share code example for my above questions. thanks


Continue reading...


Back
Top