窗体中的滚动字幕

实现效果:

  

知识运用:

  Timer组件 Lable控件的Left属性

实现代码:  

        private void button1_Click(object sender, EventArgs e)
        {
            bool validate = (button1.Text == "开始");
            if (validate)
            {
                timer1.Start();
                button1.Text = "暂停";
            }
            else { timer1.Stop(); button1.Text = "开始"; }
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            label1.Left -= 2;
            if (label1.Left < 0)
                label1.Left = this.Width;
        }

猜你喜欢

转载自www.cnblogs.com/feiyucha/p/10121578.html