0
Reply

Trying to drag+drop image form one app to another

johngbeckett

johngbeckett

Oct 20 2004 5:18 PM
1.7k
I have two applications, each with a PictureBox. How do I drag and drop the picture as is from the PictureBox in one application to the PictureBox in the other application? I'm able to drag and drop text from one app to another, but have been unsuccessful with images. I've tried this (didn't work): In source... private void pictureBoxSource_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { if (e.Button == MouseButtons.Left) { pictureBoxSource.DoDragDrop( pictureBox1.Image, DragDropEffects.Copy ); } } In target... private void pictureBoxTarget_DragEnter(object sender, System.Windows.Forms.DragEventArgs e) { if ( e.Data.GetDataPresent( DataFormats.Bitmap ) ) { e.Effect = DragDropEffects.Copy; } else e.Effect = DragDropEffects.None; } private void pictureBoxTarget_DragOver(object sender, System.Windows.Forms.DragEventArgs e { e.Effect=DragDropEffects.Copy; } private void pictureBoxTarget_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) { if ( (e.Data.GetDataPresent(DataFormats.Bitmap))) { this.pictureBoxTarget.Image = (Bitmap)(e.Data.GetData(DataFormats.Bitmap)); } }