public partial class Form1 : Form
{
bool band;
public Form1()
{
InitializeComponent();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (pictureBox1.Left < this.ClientSize.Width - pictureBox1.Width + 10 && band)
{
pictureBox1.Left++;
if (pictureBox1.Left == this.ClientSize.Width - pictureBox1.Width - 10)
{
band = false;
}
}
if (pictureBox1.Left > -10 && !band)
{
pictureBox1.Left--;
if (pictureBox1.Left == -10)
{
band = true;
}
}
}
}