bool bPictureBoxDragging = false;
        Point oPointClicked;
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            PictureBox p = (PictureBox)sender;
            pictureBox1.Cursor = Cursors.Hand;
            bPictureBoxDragging = true;
            oPointClicked = e.Location;
        }
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
        {
            if (bPictureBoxDragging)
            {
                DoubleBuffered = true;
                Point oMoveToPoint;
                oMoveToPoint = pictureBox1.PointToScreen(e.Location);
          oMoveToPoint.Offset(oPointClicked.X * -1, oPointClicked.Y * -1);
                pictureBox1.Location = oMoveToPoint;
            }
        }        private void pictureBox1_MouseUp(object sender, MouseEventArgs e)
        {
            bPictureBoxDragging = false;
            pictureBox1.Cursor = Cursors.Arrow;
        } 大家帮我看看,为什么鼠标按下移动的时候图片会跳一下??怎么解决?

解决方案 »

  1.   

    我用的vs2003,怎么MouseEventArgs e,没有Location这个属性,难道楼主用的2005?
    pictureBox1.Location = oMoveToPoint//有这句话,图片的位置当然会随鼠标变化了
      

  2.   

    你这样来做试试看:
    Point lastPoint = Point.Empty;
    private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
    {
    PictureBox box = sender as PictureBox;
    if (box.Capture)
    {
    Point loc = box.Location;
    loc.Offset(e.Location.X - lastPoint.X, e.Location.Y - lastPoint.Y);
    box.Location = loc;
    }
    }private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
    {
    lastPoint = e.Location;
    }
      

  3.   

    oMoveToPoint.Offset(oPointClicked.X * -1, oPointClicked.Y * -1);
    这句话有问题,改成楼上的方法,应该对了
      

  4.   

    是2005.
    问题解决 谢谢hbxtlhx(平民百姓)