Monday, February 9, 2009

Getting the list of files dragged on a control

There may be some situations in which there is a picture box sort of control and u r expected to drag image files on it to open them directly . To do so,we must deal with Drag Enter event.

In Drag Enter event just add the following code:

string[] Files = (string[])e.Data.GetData(DataFormats.FileDrop, false);

Where 'e' is the DragEventArg

The string array Files[] will contain the paths of the files dragged on to the control. After getting the files paths u can directly use them to get the desired functionality.

No comments:

Post a Comment