Below is a bit of code which sets up drag and drop in a treeview. This is handy for if you have a list of items that can be sorted by the user.
Here is a bit of code to demonstrate how to do this. First create a new Windows executable project. Drop a TreeView component on the form, and let's name it 'myTree' for this demonstration. Go ahead and populate it with some dummy data; enough data to see the dragging and dropping in action. You will need a variable global to the form's scope.
private TreeNode sourceNode;
This is used to track the item we are dragging in our TreeView. Then define the event handlers listed below.