我想用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);
}
请给代码在线等!!谢谢
就是与下面代码 相反意思 下面的是 从右往左
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);
}
请给代码在线等!!谢谢
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);
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);
}
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);