views:

545

answers:

1

Hi, i have a c# winform app that contains a listview control. i would like to be able to drag items from the listview onto the desktop. does any one know how to do this?

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

Ta!

+3  A: 

If you want to drag from your list view to the desktop, call DoDragDrop and create a new DataObject in the format of a FileDrop. You will need to create a temporary file to set as the file you would like 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 temp file that you will have created and create a File Drop object, so that the desktop can recognise it and allow the copy.

ThePower