一、说明

使用dev控件,TreeList1向TreeList2拖拽

二、属性

//允许拖拽
            treeList1.AllowDrop = true;
            treeList2.AllowDrop = true;
            //允许多行选择
            treeList1.OptionsSelection.MultiSelect = true;

三、代码

  1. #region tree拖拽操作
  2.  
  3. TreeListHitInfo downHitInfo = null;
  4. #region 拖出
  5. private void treeList1_MouseMove(object sender, MouseEventArgs e)
  6. {
  7. TreeList treelist = sender as TreeList;
  8. if (e.Button == MouseButtons.Left && downHitInfo != null)
  9. {
  10. if (treeList1.Selection.Count == )
  11. return;
  12. Size dragSize = SystemInformation.DragSize;
  13. Rectangle dragRect = new Rectangle(new Point(downHitInfo.MousePoint.X - dragSize.Width / ,
  14. downHitInfo.MousePoint.Y - dragSize.Height / ), dragSize);
  15.  
  16. if (!dragRect.Contains(new Point(e.X, e.Y)))
  17. {
  18. List<TreeListNode> node = new List<TreeListNode>();
  19. foreach (TreeListNode n in treeList1.Selection)
  20. {
  21. node.Add(n);
  22. }
  23. treelist.DoDragDrop(downHitInfo.Node, DragDropEffects.Move);
  24. downHitInfo = null;
  25. DevExpress.Utils.DXMouseEventArgs.GetMouseArgs(e).Handled = true;
  26. }
  27. }
  28.  
  29. }
  30.  
  31. private void treeList1_MouseDown(object sender, MouseEventArgs e)
  32. {
  33. TreeList treelist = sender as TreeList;
  34. downHitInfo = null;
  35. TreeListHitInfo hitInfo = treelist.CalcHitInfo(new Point(e.X, e.Y));
  36.  
  37. if (Control.ModifierKeys != Keys.None) return;
  38. if (e.Button == MouseButtons.Left)
  39. {
  40. downHitInfo = hitInfo;
  41. }
  42. }
  43.  
  44. #endregion
  45.  
  46. #region 拖入
  47. private void treeList2_DragOver(object sender, DragEventArgs e)
  48. {
  49. TreeList treelist = sender as TreeList;
  50. if (treelist != null)
  51. {
  52. e.Effect = DragDropEffects.Move;
  53. }
  54. }
  55.  
  56. private void treeList2_DragEnter(object sender, DragEventArgs e)
  57. {
  58. e.Effect = DragDropEffects.Move;
  59. }
  60.  
  61. private void treeList2_DragDrop(object sender, DragEventArgs e)
  62. {
  63. List<TreeListNode> nodes = e.Data.GetData(typeof(List<TreeListNode>)) as List<TreeListNode>;
  64. TreeList grid = sender as TreeList;
  65. DataTable table = grid.DataSource as DataTable;
  66.  
  67. if (nodes != null && nodes.Count > && table != null)
  68. {
  69. foreach (TreeListNode node in nodes)
  70. {
  71. treeList1.Nodes.Add(node);
  72. }
  73. }
  74. }
  75. #endregion
  76. #endregion

dev TreeList拖拽的更多相关文章

  1. Dev Grid拖拽移动行

    效果图 源码下载 拖拽时带行截图效果实现代码 /// <summary> /// 拖拽帮助类 /// </summary> public static class DragHe ...

  2. dev gridview拖拽数据移动

    设置属性gridView1.OptionsSelection.EnableAppearanceFocusedCell = false; //确保选定行的背景色一样. private BindingLi ...

  3. 浅谈DevExpress<四>:TreeList中的拖拽功能

    本篇要实现的目标,简单来说就是把一个treelist的节点用鼠标拖到另外的节点(自身或其他的listview)上,如下图: 1 

  4. Dev GridView行拖拽

    http://blog.csdn.net/keyrainie/article/details/8513802 http://www.cnblogs.com/qq4004229/archive/2012 ...

  5. dev GridControl实现拖拽

    一.示例说明 以gridControl1和gridControl2为例,从gridControl1拖拽行到gridControl2中去. 二.属性设置 gridControl2.AllowDrop = ...

  6. dev gridview 单元格值拖拽替换

    public class GridViewDropCell { //dvginfo根据鼠标点击的x.y坐标获取该点的相关信息 private GridHitInfo downHitInfo; priv ...

  7. Html5+NodeJS——拖拽多个文件上传到服务器

    实现多文件拖拽上传的简易Node项目,可以在github上下载,你可以先下载下来:https://github.com/Johnharvy/upLoadFiles/. 解开下载下的zip格式包,建议用 ...

  8. React Editor 应用编辑器(1) - 拖拽功能剖析

    这是可视化编辑器 Gaea-Editor 的第一篇连载分析文章,希望我能在有限的篇幅讲清楚制作这个网页编辑器的动机,以及可能带来的美好使用前景(画大饼).它会具有如下几个特征: 运行在网页 文档流布局 ...

  9. 【百度地图API】如何制作可拖拽的沿道路测距

    原文:[百度地图API]如何制作可拖拽的沿道路测距 摘要: 地图测距,大家都会,不就map.getDistance麼.可是,这只能测任意两点的直线距离,用途不够实际啊.比如,我想测试北京天安门到北京后 ...

随机推荐

  1. apache 虚拟目录

    补充:必须使用80端口才能正常使用  C:\Windows\System32\drivers\etc\hosts 最后添加上: 127.0.0.1 shenyi.com 127.0.0.1 offli ...

  2. 人工神经网络NN

    [面向代码]学习 Deep Learning系列 http://blog.csdn.net/coolluyu/article/details/20214617 正则化的最小二乘法 深入浅出LSTM神经 ...

  3. Git 恢复某个文件指定版本

    1. git reflog  找到comit id 2. git reset edf92f a.txt 3. git commit -m "ssss" 4. git checkou ...

  4. Python 中的枚举类型~转

    Python 中的枚举类型 摘要: 枚举类型可以看作是一种标签或是一系列常量的集合,通常用于表示某些特定的有限集合,例如星期.月份.状态等. 枚举类型可以看作是一种标签或是一系列常量的集合,通常用于表 ...

  5. maven 依赖

    依赖排除 当一个项目A依赖项目B,而项目B同时依赖项目C,如果项目A中因为各种原因不想引用项目C,在配置项目B的依赖时,可以排除对C的依赖. 示例(假设配置的是A的pom.xml,依赖关系为:A -- ...

  6. 著名的sql注入问题-问题的原因分析及总结

    Statement安全漏洞(sql注入问题)问题展示: 首先我的Mysql数据库中有一张users表,如下图所示 /** * 根据用户名查询用户 * @param username 需要查询的用户名 ...

  7. ubuntu不能正常登录

    在ubuntu登录界面,输入密码后,出现一个界面后一闪而过又返回登录界面.查看auth.log发现如下错误 May 15 15:42:19 tim-vm lightdm: pam_unix(light ...

  8. Open Live Writer 安装

    Open Live Writer来源 Windows Live Writer在2012年就停止了更新,Open Live Writer是由Windows Live WriterWriter更名而来,是 ...

  9. LeetCode Design Hit Counter

    原题链接在这里:https://leetcode.com/problems/design-hit-counter/. 题目: Design a hit counter which counts the ...

  10. 高级java必会系列一:多线程的简单使用

    众所周知,开启线程2种方法:第一是实现Runable接口,第二继承Thread类.(当然内部类也算...)常用的,这里就不再赘述.本章主要分析总结线程池和常用调度类. 一.线程池 1.newCache ...