I am making a drapandrop and it's working nice. But I want it to give a message whenever I try to drag an image into a picture that already contains one, that won't work... When I click on an image and drag it to the same picturebox where it came from (like I click on picturebox1 and drop it on picturebox1 it just gets blank), it just disappears.public partial class Form1 : Form
public Form1()
{
InitializeComponent();
pictureBox1.AllowDrop = true;
pictureBox2.AllowDrop = true;
pictureBox3.AllowDrop = true;
pictureBox4.AllowDrop = true;
pictureBox5.AllowDrop = true;
pictureBox6.AllowDrop = true;
}
void pictureBox_MouseDown(object sender, MouseEventArgs e)
{
DoDragDrop(sender, DragDropEffects.Move);
}
void pictureBox_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}
void pictureBox_DragDrop(object sender, DragEventArgs e)
{
PictureBox pb = e.Data.GetData(typeof(PictureBox)) as PictureBox;
if (pb.Image != null)
{
((PictureBox)sender).Image = pb.Image;
pb.Image = null;
}
else
{
MessageBox.Show("The picturebox already contains an image.");
}
}
}
}