MainForm.TreeView_DragDrop C# (CSharp) Метод

TreeView_DragDrop() публичный Метод

public TreeView_DragDrop ( object sender, DragEventArgs e ) : void
sender object
e DragEventArgs
Результат void
	void TreeView_DragDrop (object sender, DragEventArgs e)
	{
		// Retrieve the client coordinates of the drop location.
		Point targetPoint = _treeView.PointToClient (new Point (e.X, e.Y));

		// Retrieve the node at the drop location
		TreeNode targetNode = _treeView.GetNodeAt (targetPoint);

		// 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 or a descendant of the dragged node.
		if (draggedNode != targetNode && !ContainsNode (draggedNode, targetNode)) {
			// If it is a move operation, remove the node from its current 
			// location and add it to the node at the drop location.
			if (e.Effect == DragDropEffects.Move) {
				_eventsText.AppendText ("DragDrop (Move): " + draggedNode.Text
					+ " => " + targetNode.Text + Environment.NewLine);

				draggedNode.Remove ();
				targetNode.Nodes.Add (draggedNode);
			}

			// If it is a copy operation, clone the dragged node
			// and add it to the node at the drop location
			if (e.Effect == DragDropEffects.Copy) {
				_eventsText.AppendText ("DragDrop (Move): " + draggedNode.Text
					+ " => " + targetNode.Text + Environment.NewLine);

				targetNode.Nodes.Add ((TreeNode) draggedNode.Clone ());
			}

			// Expand the node at the location 
			// to show the dropped node.
			targetNode.Expand ();
		} else {
			_eventsText.AppendText ("DragDrop (Descendant): " + draggedNode.Text
				+ " => " + targetNode.Text + Environment.NewLine);
		}
	}
MainForm