判断下计时器当前状态,赋值为当前状态的相对状态就行了。如二楼所说,主要是计时器的Enable属性的转换。举个例子,假设窗体中我们放置了个label,id为lblShowTime,用来获取当前时间。
private void Form1_Load(object sender, EventArgs e)
{
this.timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.lblShowTime.Text = DateTime.Now.ToString();
}
private void lblShowTime_Click(object sender, EventArgs e)
{
this.timer1.Enabled = !this.timer1.Enabled;
}
[
本帖最后由 lane916 于 2012-6-7 15:01 编辑 ]