コード例 #1
0
        private void tvTree_DragDrop(object sender, DragEventArgs e)
        {
            TreeNode sourceNode;
            TreeNode destinationNode;
            bool     result;

            // Get the tree.
            TreeView tree = (TreeView)sender;

            // Get the screen point.
            Point pt = new Point(e.X, e.Y);

            // Convert to a point in the TreeView's coordinate system.
            pt = tree.PointToClient(pt);

            // Get the node underneath the mouse.
            destinationNode = tree.GetNodeAt(pt);
            sourceNode      = (TreeNode)e.Data.GetData(typeof(TreeNode));

            result = templatesMenager.Copy(sourceNode, destinationNode);

            if (result == true)
            {
                // Add a child node.
                destinationNode.Nodes.Add((TreeNode)sourceNode.Clone());

                // Show the newly added node if it is not already visible.
                destinationNode.Expand();
                tvTree.Nodes.Remove(sourceNode);
                templatesMenager.LoadAll();
            }
        }