Most Windows Forms objects in C# have an AllowDrop property, this must be set in order for that to work.
You must also provide methods for the Drag Drop events, ie - DragEnter and DragDrop.
Here's an example for dragging an image file onto a PictureBox (I apologize for the formatting):
private void pictureBox1_DragEnter( object sender, DragEventArgs e )
{
// check drop data type
if ( e.Data.GetDataPresent( DataFormats.FileDrop, false )
{
e.Effect = DragDropEffects.All;
}
}
private void pictureBox1_DragDrop( object sender, DragEventArgs e )
{
// get dropped items
string[ dropped = (string[)e.Data.GetData( DataFormats.FileDrop );
// only inspect the first item
FileInfo fileInfo = new FileInfo( dropped[0] );
// make sure it's a valid file
if ( fileInfo.Exists )
{
// make sure it's a bitmap
if ( fileInfo.Extension.ToLower() == ".png" )
{
// details elided
}
}
}
You'll also need to include an implementation for MouseDown for your control (in this case, your list)
// this is a bad example for you, but works for selecting the background image of a panel for drag/drop
private void panel_MouseDown(object sender, MouseEventArgs e)
{
Panel source = (Panel)sender;
DoDragDrop( source.BackgroundImage, DragDropEffects.Copy );
}