读书人

小弟初学 请教 C# 倒计时器如何写 时间

发布时间: 2011-12-17 23:37:33 作者: rapoo

小弟初学 请教 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;

读书人网 >C#

热点推荐