当前位置:编程学习 > C#/ASP.NET >>

C#timer控件

想编写一段程序,能够在一秒的时候执行button1的职能,2秒的时候执行button2 的职能,3秒的时候执行button3的职能,也就是在不同的时间执行不同的内容,不知道如何实现,谁能给一段实例程序~~ --------------------编程问答--------------------

this.timer2.Interval = 1000;

        int i = 0;
        private void timer2_Tick(object sender, EventArgs e)
        {
            if (i = 0)
            {
                this.button1.PerformClick();
                i = 1;
            }
            else if (i = 1)
            {
                this.button2.PerformClick();
                i = 2;
            }
            else if (i = 2)
            {
                this.button3.PerformClick();
                i = 3;
            }
        }


--------------------编程问答-------------------- 或者:

this.timer1.Interval = 1000;
this.timer2.Interval = 1000;
this.timer3.Interval = 1000;

----------------

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.timer1.Enabled = false;
            this.button1.PerformClick();
            this.timer2.Enabled = true;
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            this.timer2.Enabled = false;
            this.button1.PerformClick();
            this.timer3.Enabled = true;
        }

        private void timer3_Tick(object sender, EventArgs e)
        {
            this.timer3.Enabled = false;
            this.button1.PerformClick();
        }
--------------------编程问答-------------------- 改错:
timer2执行button2
timer3执行button3
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,