C # Drag a node using listview

Source: Internet
Author: User
/// <Summary> /// triggered when a certain item is dragged /// </Summary> /// <Param name = "sender"> </param> /// <Param name = "E"> </param> private void listview1_itemdrag (Object sender, itemdrageventargs e) {listview1.dodragdrop (E. item, dragdropeffects. move );} /// <summary> /// drag an item to the control area /// </Summary> /// <Param name = "sender"> </param> /// <Param name = "E"> </param> private void listviewincludragenter (Object sender, drageventargs E) {e. effect = dragdropeffects. move ;} /// <summary> /// when dragging an item to the top of a row, /// </Summary> /// <Param name = "sender"> </Param >/// <Param name = "E"> </param> private void listviewdomaindragover (Object sender, drageventargs e) {point ptscreen = new point (e. x, E. y); point Pt = listview1.pointtoclient (ptscreen); listviewitem item = listview1.getitemat (pt. x, PT. y); If (item! = NULL) item. selected = true ;} /// <summary> /// end dragging /// </Summary> /// <Param name = "sender"> </param> /// <Param name = "E"> </param> private void listviewincludragdrop (Object sender, drageventargs e) {listviewitem draggeditem = (listviewitem) E. data. getdata (typeof (listviewitem); // The old destination point ptscreen = new point (e. x, E. y); point Pt = listview1.pointtoclient (ptscreen); listviewitem targetitem = listview1.getitemat (pt. x, PT. y); // new target if (null = targetitem) {return;} If (messageboxex. show ("[" + draggeditem. text + "] Go to [" + targetitem. text + "]", "Ask", messageboxbuttons. okcancel, messageboxicon. question) = dialogresult. OK) {var item = draggeditem. tag as view_tablelistmodel; int tableid = item. ID;} // listview1.items. insert (targetitem. index, (listviewitem) draggeditem. clone (); // listview1.items. remove (draggeditem );}

 

C # Drag a node using listview

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.