日期:2014-05-17 浏览次数:21335 次
Point p = new Point();
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
p.X = e.Location.X;
p.Y = e.Location.Y;
pictureBox1.MouseMove +=pictureBox1_MouseMove;
}
private void pictureBox1_MouseMove(object sender ,MouseEventArgs e)
{
pictureBox1.Location = new Point(pictureBox1.Location.X + e.Location.X - p.X, pictureBox1.Location.Y + e.Location.Y - p.Y);
pictureBox1.MouseUp += pictureBox1_MouseUp;
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
pictureBox1.Location = new Point(p.X, p.Y);
pictureBox1.MouseMove -= pictureBox1_MouseMove;
}