点击第一个按钮启动计时器,第二个按钮停止 [英] First button click to start timer, second to stop

查看:26
本文介绍了点击第一个按钮启动计时器,第二个按钮停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力使按钮第一次点击启动计时器,第二次点击停止计时器等.

I'm struggling with making button first click to start a timer, second click to stop the timer and etc.

有人可以帮我吗?:)

private void button7_Click(object sender, EventArgs e)
{
    timer1.Start();
}

推荐答案

使用 Enabled 属性:

Use the Enabled property:

if (timer1.Enabled) {
  timer1.Stop();
} else {
  timer1.Start();
}

Enabled 属性会告诉您计时器是否正在运行.

The Enabled property tells you if the timer is running or not.

这篇关于点击第一个按钮启动计时器,第二个按钮停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆