使用十分简单,参考实例即可.(该程序使用C#/VS2005编译通过)
![](https://i-blog.csdnimg.cn/blog_migrate/179cdebb906a6f6d8c8ac90de6739267.jpeg)
只要几行代码即可,如下:
1
public
Form1()
2![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
3
InitializeComponent();
4
Init();
5
}
6![](/Images/OutliningIndicators/None.gif)
7
private
void
Init()
8![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
9
TreeViewDrager treeViewDrager = new TreeViewDrager(this.treeView1);
10
treeViewDrager.TreeImageList = this.imageList1;//不设置这个也可以,只是拖动的时候没图标。
11
treeViewDrager.ProcessDragNode += new ProcessDragNodeEventHandler(treeViewDrager_ProcessDragNode);
12
}
13![](/Images/OutliningIndicators/None.gif)
14
private
bool
treeViewDrager_ProcessDragNode(TreeNode from, TreeNode to)
15![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
16![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**////这里根据from/to两个节点记录的信息去进行数据库持久化的工作。
17
///根据持久化的结果决定节点是否会最终实现拖动操作。
18
///return false;-持久化失败,给出提示,不能完成拖动操作。
19
return true;
20
}
![](/Images/OutliningIndicators/None.gif)
2
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
3
![](/Images/OutliningIndicators/InBlock.gif)
4
![](/Images/OutliningIndicators/InBlock.gif)
5
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
6
![](/Images/OutliningIndicators/None.gif)
7
![](/Images/OutliningIndicators/None.gif)
8
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
9
![](/Images/OutliningIndicators/InBlock.gif)
10
![](/Images/OutliningIndicators/InBlock.gif)
11
![](/Images/OutliningIndicators/InBlock.gif)
12
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
13
![](/Images/OutliningIndicators/None.gif)
14
![](/Images/OutliningIndicators/None.gif)
15
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
![](https://www.cnblogs.com/Images/dot.gif)
16
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ContractedSubBlock.gif)
17
![](/Images/OutliningIndicators/InBlock.gif)
18
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
19
![](/Images/OutliningIndicators/InBlock.gif)
20
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
Demo下载: TreeViewDraperDemo
关于组件源代码请留下有效邮箱,我整理好后一起发给大家。