窗体中的滚动字幕

Posted on   努力成长静待花开  阅读(174)  评论(0编辑  收藏  举报

实现效果:

  

知识运用:

  Timer组件 Lable控件的Left属性

实现代码:  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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;
}

 

点击右上角即可分享
微信分享提示