C # dragdrop from list management

I have a winform C # application that contains a listview control. I would like to be able to drag items from a list to the desktop. Does anyone know how to do this?

I am vaguely familiar with the dodragdrop () method, but not sure of the correct implementation.

That!

+4
source share
1 answer

If you want to drag from your list onto the desktop, call DoDragDrop and create a new DataObject in the FileDrop format. You will need to create a temporary file to install as the file you want to copy.

string MyFilePath = @"C:\Documents and Settings\All Users\Temp\TempFile.txt"; listView.DoDragDrop(new DataObject(DataFormats.FileDrop, MyFilePath) , DragDropEffects.Copy); 

This will take the path of the temporary file created and create the File Drop object so that the desktop can recognize it and allow the copy.

+6
source

All Articles