namespace WindowsFormsApplication1
{
public partial class Form3 : Form
{
bool chieu;
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private void Form3_Load(object sender, EventArgs e)
{
timer1.Enabled = false;
chieu = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
if(chieu==true)
pictureBox1.Top = pictureBox1.Top + 5;
else
pictureBox1.Top=pictureBox1.Top-5;
if((pictureBox1.Top<=0)||(pictureBox1.Top+pictureBox1.Height>=this.Height))
chieu=!chieu;
}
}
}
Bạn đang đọc truyện trên: Truyen2U.Pro