Hi, Im trying to move a picturebox in a panel by moving the mouse. Here is the code I'm using:
System.Drawing.Point p;
bool move;
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
p.X = e.X;
p.Y = e.Y;
move = true;
}
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (move)
{
pictureBox1.Left += e.X - p.X;
}
}
private void panel1_MouseUp(object sender, MouseEventArgs e)
{
move = false;
}
Nevertheless it does not woek, the picturebox dissapears from the form. If I use the same code on the PictureBox events it works just fine, however I want to move the picturebox by clickin in any part of the form.
Thanks in advance