简体   繁体   中英

Drag and Drop ListView to Listview(Listbox)

I´m writing a little audio player in c#.

Now I want drag and drop some Items from my music library (ListView) to a playlist(ListView or Listbox).

Will this work?

Im using Windows Forms, what is the best way to solve this problem?

Yes it will work. Just prepare the Playlist control:

((Control)PlayList).AllowDrop = true;
PlayList.DragEnter += PlayList_DragEnter;
PlayList.DragDrop += PlayList_DragDrop;

And initiate drag from Library ListView:

DoDragDrop( new DataObject( DataFormats.FileDrop, paths ), DragDropEffects.Link );

(Just modify the parameters as you need)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM