<分区>
我是编程新手,我遇到了这个问题,这对我来说听起来很简单,但我太笨了,搞不懂。
所以...我想在我的窗体上制作一个Timer
,它以一个Button
开头,然后是相同的Button
阻止它。并且在屏幕上有一个 Label
,它只显示 Timer
已经进行了多少次滴答。
private void BtnStart_Click(object sender, EventArgs e)
{
if (timer1.Enabled)
timer1.Enabled = false;
if (!timer1.Enabled)
timer1.Enabled = true;
}
int c = 0;
private void Timer1_Tick(object sender, EventArgs e)
{
c++;
lblTimer.Text = c.ToString();
}
第一个按钮点击有效,它从 Timer
开始,Label
显示计数器,但我认为它进入了一个无限循环,阻止了按钮再次按下,因为我无法停止 Timer
?有人可以启发我我做错了什么吗?
谢谢!