D
dk60
I want to allow the user of my application to drag a picture box
around, so I wrote these simple event handlers:
private void pictureBox1_MouseDown(object sender,
MouseEventArgs e)
{
pictureBox1Movable = true;
}
private void pictureBox1_MouseMove(object sender,
MouseEventArgs e)
{
if (pictureBox1Movable==true)
{
Point p = pictureBox1.Location;
p.X += e.X;
p.Y += e.Y;
pictureBox1.Location = p;
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs
e)
{
pictureBox1Movable = false;
}
However, when the user starts dragging, the picture box "jumps" so
that the upper left corner coincides with the mouse pointer and after
that the dragging goes fine. I cannot find a way to fix it. I tried
several ideas but none works. This looks like a simple matter that
should have a straightforward solution.
around, so I wrote these simple event handlers:
private void pictureBox1_MouseDown(object sender,
MouseEventArgs e)
{
pictureBox1Movable = true;
}
private void pictureBox1_MouseMove(object sender,
MouseEventArgs e)
{
if (pictureBox1Movable==true)
{
Point p = pictureBox1.Location;
p.X += e.X;
p.Y += e.Y;
pictureBox1.Location = p;
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs
e)
{
pictureBox1Movable = false;
}
However, when the user starts dragging, the picture box "jumps" so
that the upper left corner coincides with the mouse pointer and after
that the dragging goes fine. I cannot find a way to fix it. I tried
several ideas but none works. This looks like a simple matter that
should have a straightforward solution.