Dev Treelist Drag

Source: Internet
Author: User

I. Description

Using the dev control, TreeList1 drag to TreeList2

Second, the attribute

Allow drag and drop
Treelist1.allowdrop = true;
Treelist2.allowdrop = true;
Allow multi-line selection
TreeList1.OptionsSelection.MultiSelect = true;

Third, the Code

        #regionTree drag and drop operationTreelisthitinfo Downhitinfo=NULL; #regionDrag outPrivate voidTreelist1_mousemove (Objectsender, MouseEventArgs e) {treelist treelist= Sender astreelist; if(E.button = = MouseButtons.Left && Downhitinfo! =NULL)            {                if(TreeList1.Selection.Count = =0)                    return; Size dragsize=systeminformation.dragsize; Rectangle Dragrect=NewRectangle (NewPoint (Downhitinfo.mousepoint.x-dragsize.width/2, Downhitinfo.mousepoint.y-Dragsize.height/2), dragsize); if(!dragrect.contains (NewPoint (e.x, e.y))) {List<TreeListNode> node =NewList<treelistnode>(); foreach(Treelistnode Ninchtreelist1.selection) {node.                    ADD (n); } treelist.                    DoDragDrop (Downhitinfo.node, DragDropEffects.Move); Downhitinfo=NULL; DevExpress.Utils.DXMouseEventArgs.GetMouseArgs (E). Handled=true; }            }                    }        Private voidTreelist1_mousedown (Objectsender, MouseEventArgs e) {treelist treelist= Sender astreelist; Downhitinfo=NULL; Treelisthitinfo Hitinfo= Treelist. Calchitinfo (NewPoint (e.x, e.y)); if(Control.modifierkeys! = Keys.none)return; if(E.button = =mousebuttons.left) {downhitinfo=Hitinfo; }        }        #endregion        #regionDrag inPrivate voidTreelist2_dragover (Objectsender, DragEventArgs e) {treelist treelist= Sender astreelist; if(Treelist! =NULL) {e.effect=DragDropEffects.Move; }        }        Private voidTreelist2_dragenter (Objectsender, DragEventArgs e) {E.effect=DragDropEffects.Move; }        Private voidTreelist2_dragdrop (Objectsender, DragEventArgs e) {List<TreeListNode> nodes = e.Data.GetData (typeof(list<treelistnode>)) asList<treelistnode>; Treelist Grid= Sender astreelist; DataTable Table= Grid. DataSource asDataTable; if(Nodes! =NULL&& nodes. Count >0&& Table! =NULL)            {                foreach(Treelistnode nodeinchnodes)                {TREELIST1.NODES.ADD (node); }            }        }        #endregion        #endregion

Dev Treelist Drag

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.