basiquement :
dans le constructeur du Form, apres InitializeComponents :
pictureBox2.AllowDrop = true;
méthode associée à l'event MouseDown du pb source :
private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
pictureBox1.DoDragDrop(pictureBox1.Image, DragDropEffects.Copy);
}
méthode associée à l'event DragEnter du pb cible :
private void pictureBox2_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.Bitmap))
e.Effect = DragDropEffects.Copy;
else
e.Effect = DragDropEffects.None;
}
méthode associée à l'event DragDrop du pb cible :
private void pictureBox2_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
pictureBox2.Image = (Image)e.Data.GetData(DataFormats.Bitmap);
}
Cocoricoooooooo !!!!
coq
MVP Visual C#