特别注释:
timer控件默认是不能用的,需要将Enable设为true,并且interval设置为1000(用秒计时)
namespace test_winform
{
public partial class Form1 : Form
{
int i = 0; //用于减数计算
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void timer1_Tick_1(object sender, EventArgs e)
{
if ((5 - i) == 1)//从5开始到计时
{
timer1.Enabled = false;
}
else
{
i++;
label1.Text = (5 - i).ToString();
}
}
}
}