DevExpress XtraTreeList 节点拖拽
来源:互联网 发布:王兀 中国好歌曲 知乎 编辑:程序博客网 时间:2024/05/20 21:21
using System;using System.Drawing;using System.Collections;using System.ComponentModel;using System.Windows.Forms;using System.Data;using DevExpress.XtraTreeList;using DevExpress.XtraTreeList.Nodes;namespace DragDropReorder { /// <summary> /// Summary description for Form1. /// </summary> public class Form1 : System.Windows.Forms.Form { private DevExpress.XtraTreeList.TreeList treeList1; /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null; public Form1() { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // } /// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.treeList1 = new DevExpress.XtraTreeList.TreeList(); ((System.ComponentModel.ISupportInitialize)(this.treeList1)).BeginInit(); this.SuspendLayout(); // // treeList1 // this.treeList1.Dock = System.Windows.Forms.DockStyle.Fill; this.treeList1.Location = new System.Drawing.Point(0, 0); this.treeList1.Name = "treeList1"; this.treeList1.Size = new System.Drawing.Size(422, 277); this.treeList1.TabIndex = 0; this.treeList1.CalcNodeDragImageIndex += new DevExpress.XtraTreeList.CalcNodeDragImageIndexEventHandler(this.treeList1_CalcNodeDragImageIndex); this.treeList1.DragOver += new System.Windows.Forms.DragEventHandler(this.treeList1_DragOver); this.treeList1.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeList1_DragDrop); // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(422, 277); this.Controls.Add(this.treeList1); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHandler(this.Form1_Load); ((System.ComponentModel.ISupportInitialize)(this.treeList1)).EndInit(); this.ResumeLayout(false); } #endregion /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } private void Form1_Load(object sender, System.EventArgs e) { new DevExpress.XtraTreeList.Design.XViews(treeList1); treeList1.OptionsBehavior.DragNodes = true; } private DragDropEffects GetDragDropEffect(TreeList tl, TreeListNode dragNode) { TreeListNode targetNode; Point p = tl.PointToClient(MousePosition); targetNode = tl.CalcHitInfo(p).Node; if(dragNode != null && targetNode != null && dragNode != targetNode && dragNode.ParentNode == targetNode.ParentNode) return DragDropEffects.Move; else return DragDropEffects.None; } private void treeList1_DragOver(object sender, System.Windows.Forms.DragEventArgs e) { TreeListNode dragNode = e.Data.GetData(typeof(TreeListNode)) as TreeListNode; e.Effect = GetDragDropEffect(sender as TreeList, dragNode); } private void treeList1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { TreeListNode dragNode, targetNode; TreeList tl = sender as TreeList; Point p = tl.PointToClient(new Point(e.X, e.Y)); dragNode = e.Data.GetData(typeof(TreeListNode)) as TreeListNode; targetNode = tl.CalcHitInfo(p).Node; tl.SetNodeIndex(dragNode, tl.GetNodeIndex(targetNode)); e.Effect = DragDropEffects.None; } private void treeList1_CalcNodeDragImageIndex(object sender, DevExpress.XtraTreeList.CalcNodeDragImageIndexEventArgs e) { TreeList tl = sender as TreeList; if(GetDragDropEffect(tl, tl.FocusedNode) == DragDropEffects.None) e.ImageIndex = -1; // no icon else e.ImageIndex = 1; // the reorder icon (a curved arrow) } }}
0 0
- DevExpress XtraTreeList 节点拖拽
- DevExpress.xtraTreeList
- c# DevExpress.XtraTreeList 树形节点的上下移动
- DevExpress.XtraTreeList 操作大全
- DevExpress.XtraTreeList 操作大全
- DevExpress控件之XtraTreeList
- DevExpress.XtraTreeList.TreeList 控件如何找到当前被选中的节点
- DevExpress.XtraTreeList.TreeList 显示行号
- 关于DevExpress.XtraTreeList.TreeList 使用
- DevExpress.XtraTreeList.TreeList 显示行号
- XtraTreelist添加节点图片
- 关于DevExpress.xtraTreeList的使用小集锦。
- 关于DevExpress的XtraTreeList使用方法总结
- 利用递归绑定DevExpress.XtratreeList.TreeList数据
- 关于DevExpress的XtraTreeList使用方法总结
- DevExpress控件XtraTreeList的使用心得
- DevExpress.XtraTreeList.TreeList (树控件使用说明)
- 树形列表成员- DevExpress.XtraTreeList.TreeList
- SQL Server中批处理的知识点
- linux删除多级非空目录
- 一些好的博客
- Java HashMap遍历
- 队列逆置
- DevExpress XtraTreeList 节点拖拽
- 常用字符串函数
- 大国的思维
- HDU1247 Hat’s Words
- 第六章 APO文件目录系统
- leetCode解题报告5道题(四)
- job1003 A+B
- Eclipse集成Maven
- LeetCode: Remove Duplicates from Sorted List