Timer无法运行
timer没有启动怎么回事?编译没有发现问题
namespace WinFormsApp_Timer01
{
public partial class Form1 : Form
{
//定义全局变量
int iCount;
int iCountMax;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
int i = 1;
for (i = 1; i<=100; i++)
{
comboBox1.Items.Add(i.ToString() + "秒");
lblTimRemain.Text = iCountMax.ToString();
}
}
private void btn_Click(object sender, EventArgs e)
{
string strTimeItemText = comboBox1.Text;
int iTimeItemTextLen = comboBox1.Text.Length;
string strTimeItemTextNew = comboBox1.Text.Remove(iTimeItemTextLen - 1, 1);
iCountMax = Convert.ToUInt16(strTimeItemTextNew);
iCount = iCountMax;
progressBar1.Maximum = iCountMax;
lblTimRemain.Text = iCountMax.ToString() + " 秒";
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
progressBar1.Value = iCount;
lblTimRemain.Text = iCount.ToString() + " 秒";
iCount--;
if (iCount<=0)
{
timer1.Stop();
MessageBox.Show("时间到达");
}
}
}
}
enable 没有?
页:
[1]