First button click to start timer, second to stop

前端 未结 5 660
独厮守ぢ
独厮守ぢ 2021-01-28 05:04

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

Can anybody help me? :)

private void button7_Cli         


        
5条回答
  •  时光说笑
    2021-01-28 05:31

    Use the Enabled property:

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

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

提交回复
热议问题