zl程序教程

您现在的位置是:首页 >  其它

当前栏目

窗体中的滚动字幕

滚动 窗体 字幕
2023-09-14 08:58:58 时间

实现效果:

  

知识运用:

  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;
        }