To move a control you only need the
MouseDown
and
MouseMove
event handlers if you do it like;
void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
PictureBox picBox = sender as PictureBox;
picBox.Tag = e.Location;
}
}
void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
PictureBox picBox = sender as PictureBox;
if (e.Button == MouseButtons.Left && picBox.Tag != null)
{
Point lastLocation = (Point)picBox.Tag;
picBox.Top = picBox.Top + (e.Location.Y - lastLocation.Y);
picBox.Left = picBox.Left + (e.Location.X - lastLocation.X);
}
}