2024年终活动

DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

怎样将一个DevExpress XtraTreeList节点拖到另一个XtraTreeList中

来源:本站   发布时间:2012-03-01   浏览:4530次

先获取选中的节点,再处理将节点拖入另一个XtratreeList时的OnDragDrop方法。

关键代码:

private void OnDragEnter(object sender, DragEventArgs e)

        {

            TreeList list = (TreeList)sender;

            TreeListNode node = GetDragNode(e.Data);

            if (node != null && node.TreeList != list)

                e.Effect = DragDropEffects.Copy;

        }

 

        private void OnDragDrop(object sender, DragEventArgs e)

        {

            TreeListNode node = GetDragNode(e.Data);

            if (node == null) return;

            TreeList list = (TreeList)sender;

            if (list == node.TreeList) return;

            TreeListHitInfo info = list.CalcHitInfo(list.PointToClient(new Point(e.X, e.Y)));

            InsertBrunch(list, node, info.Node == null ? -1 : info.Node.Id);

        }

 

        private void InsertBrunch(TreeList list, TreeListNode node, int parent) {

            ArrayList data = new ArrayList();

            foreach (TreeListColumn column in node.TreeList.Columns)

                data.Add(node[column]);

            parent = list.AppendNode(data.ToArray(), parent).Id;

 

            //如果拖拽节点有子节点,将子节点也一起拖入

            if (node.HasChildren)

                foreach (TreeListNode n in node.Nodes)

                    InsertBrunch(list, n, parent);

        }

点击下载示例

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/135.html
扫码咨询
电话咨询
023-68661681
返回
顶部