首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

小弟初学 请教 C# 倒计时器如何写 时间是用户输入

2011-12-17 
小弟初学 请教 C# 倒计时器怎么写 时间是用户输入usingSystemusingSystem.Collections.GenericusingSyst

小弟初学 请教 C# 倒计时器怎么写 时间是用户输入
using   System;
using   System.Collections.Generic;
using   System.ComponentModel;
using   System.Data;
using   System.Drawing;
using   System.Text;
using   System.Windows.Forms;

namespace   WindowsApplication7
{
        public   partial   class   Form1   :   Form
        {
                private   int   second   =   0;

                public   Form1()
                {
                        InitializeComponent();
                }

                private   void   button1_Click(object   sender,   EventArgs   e)
                {
                        second   =   Convert.ToInt32(textBox1.Text);
                }

                private   void   timer1_Tick(object   sender,   EventArgs   e)
                {
                        if   (second   >   0)
                        {
                                label1.Text   =   second.ToString();
                                second--;
                        }
                }
        }
}

怎么改啊

[解决办法]
button1_Click中加上
this.timer1.Interval = 1000;
this.timer1.Enabled = true;

热点排行