.NET TreeView FAQ - Drag and Drop Right Click Menu

Working with a Windows Forms .NET TreeView control? This article contains code samples for the most common questions I've recevied. Things such as right click on nodes to show context menues, drag and drop nodes on the same TreeView or even another control, nudge nodes up and down in sibling order, and much more.

1.  Right Click Show Context Menu:

Code

 

2.  Show Context Menu dynamically on selected node.
     This method uses the placement on screen of the
     selected node.  ContextMenus can be draw by position.
     Also, you could just as easily programmatically create
     the ContextMenu versus passing one in like this:

Code

 

3.  Nudge TreeNode Sibling Order Up Or Down:

 

Code

 

4.  Drag And Drop On Same TreeView or Different Treeview Control.
    Download the code sample for additional information.

 

Code

 

Please download the working sample.  It is derived from an old article I did
on an alternative approach concerning data binding a DataSet to a TreeView.

Download.

posted @ 2009-01-19 15:28  海洋——海纳百川,有容乃大.  阅读(366)  评论(0编辑  收藏  举报