我想用pictureBox1 在form中从左往右运动 当从窗口中消失时 又从左面出来!!!
就是与下面代码 相反意思   下面的是 从右往左 
private void timer1_Tick(object sender, EventArgs e)
        {
            int x2 = pictureBox2.Left;
            int y2 = pictureBox2.Top;
            int w2 = pictureBox2.Width;
            int h2 = pictureBox2.Height;
            x2 -= 10;            if (x2 <= -pictureBox2.Width)
            {
                x2 = this.Width;
            }
            pictureBox2.SetBounds(x2, y2, w2, h2); 
        }
请给代码在线等!!谢谢

解决方案 »

  1.   

                int x2 = pictureBox2.Left;
                int y2 = pictureBox2.Top;
                int w2 = pictureBox2.Width;
                int h2 = pictureBox2.Height;
                x2 += 10;            if (x2 > this.Width)
                {
                    x2 = -w2;
                }
                pictureBox2.SetBounds(x2, y2, w2, h2);
      

  2.   


            private void timer1_Tick(object sender, EventArgs e)
            {
                int x2 = pictureBox1.Left;
                int y2 = pictureBox1.Top;
                int w2 = pictureBox1.Width;
                int h2 = pictureBox1.Height;
                x2 += 10;            if (x2 + w2 >= this.Width + pictureBox1.Width)
                {
                    x2 = -pictureBox1.Width;
                }
                pictureBox1.SetBounds(x2, y2, w2, h2);
            }
      

  3.   

    int x2 = pictureBox2.Left; 
                int y2 = pictureBox2.Top; 
                int w2 = pictureBox2.Width; 
                int h2 = pictureBox2.Height; 
                x2 += w2+10; 
                if (x2 > this.Width) 
                { 
                    x2 = -w2/2; 
                } 
                pictureBox2.SetBounds(x2, y2, w2, h2);