C# 像网页图片滚动一样的动画效果
public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { this.timer1.Enabled = true; //计时器可用 } private void timer1_Tick(object sender, EventArgs e) { this.panel1.Left = this.panel1.Left 10; if (this.panel1.Left > this.Width 10) { this.panel1.Left = - this.panel1.Width; } } private void pictureBox1_MouseEnter(object sender, EventArgs e) { timer1.Enabled = false; } private void pictureBox1_MouseLeave(object sender, EventArgs e) { timer1.Enabled = true; } private void pictureBox2_MouseLeave(object sender, EventArgs e) { timer1.Enabled = true; } private void pictureBox2_MouseEnter(object sender, EventArgs e) { timer1.Enabled = false; } private void pictureBox3_MouseEnter(object sender, EventArgs e) { timer1.Enabled = false; } private void pictureBox3_MouseLeave(object sender, EventArgs e) { timer1.Enabled = true; } }
评论