滾動字條動畫!

來源:互聯網
上載者:User

利用計時器控制標籤的位置從而實現滾動字幕動畫表單效果。雙擊滾動字幕,就可以退出程式。

製作要點:

1.表單的TransparencyKey屬性的應用。

2.表單的WindowState屬性的應用。

3.計時器控制項的應用。

4.標籤控制項的應用。

5.if條件陳述式的應用。

製作步驟:

1.建立一個Windows表單應用程式。設定"FormBorderStyle"屬性為"None","TransparencyKey"屬性為"Control"。

2.添加一個Label控制項,設定"Text"屬性為“滾動字幕動畫表單”,"BackColor"屬性為“淡黃色”,設定"Font"為“宋體——粗體——小三”。

3.添加一個timer控制項。

添加代碼:

private void Form1_Load(object sender, EventArgs e)
        {
            this.timer1.Interval = 10;
            this.timer1.Enabled = true;

             //表單最大化
            this.WindowState = FormWindowState.Maximized;
        }

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

        private void label1_Click(object sender, EventArgs e)
        {

           //關閉表單
            this.Close();
        }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.