110,534
社区成员
发帖
与我相关
我的任务
分享
public void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
if (pictureBox1.Image != null)
{
a = e.Location.X;
b = e.Location.Y;
pictureBox1.Cursor = System.Windows.Forms.Cursors.Hand;
}
}
private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
{
pictureBox1.Cursor = System.Windows.Forms.Cursors.Default;
c = e.Location.X;
d = e.Location.Y;
locateX += (c - a);
locateY += (d - b);
Graphics g = pictureBox1.CreateGraphics();
g.Clear(SystemColors.Control);
g.DrawImage(pictureBox1.Image, locateX, locateY,
pictureBox1.Image.Width , pictureBox1.Image.Height);
g.Dispose();
}