请帮我编一段用C#编的倒计时程序!时间由用户设定,再说一下要在窗体上加什么组件(如timer,textbox等)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TimerPlus
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int mytime = 0;
private void Form1_Load(object sender, EventArgs e)
{
this.timer1.Enabled = false;
this.textBox1.Text = "";
this.button1.Text = "点击启动倒计时";
}
private void button1_Click(object sender, EventArgs e)
{
if (this.textBox1.Text.Trim() != "")
{
this.timer1.Enabled = true;
this.timer1.Interval = 1000;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
mytime = Convert.ToInt32(textBox1.Text);
if (mytime > 0)
{
mytime -= 1;
this.textBox1.Text = mytime.ToString();
}
else
{
this.timer1.Enabled = false;
this.button1.Text = "倒计时结束";
}
}
}
}
为什么启动了之后没有反应呢