It depends what you are dragging, but...
It's a two stage process: you need to enable drop in the destination form (this uses files)
1) Set the AllowDrop property of your form to True
2) Create a handler for both the DragEnter and DragDrop events of your form.
3) In the DragEnter handler, add the following line of code:
e.Effect = DragDropEffects.Move;
4) In the DragDrop handler, add the following:
string[] files = (string[]) e.Data.GetData(DataFormats.FileDrop);
if (files != null)
{
foreach (string file in files)
{
Console.WriteLine(file);
}
}
In your source form, it's a little more complex, as you need to use a control that supports dragging, such as the ListView.
1) Handle the controls ItemDrag event. In this case, a ListView:
private void myListView_ItemDrag(object sender, ItemDragEventArgs e)
{
StringCollection s = new StringCollection();
s.Add(@"D:\Test Data\MyPic.jpg");
DataObject obj = new DataObject();
obj.SetFileDropList(s);
myListView.DoDragDrop(obj, DragDropEffects.Copy);
}
2) That's it!