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_Click(object sender, EventArgs e)
{
timer1.Start();
}
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_Click(object sender, EventArgs e)
{
timer1.Start();
}
When you start a timer, its
Enabled
property is changed toTrue
. And when youStop
it, it is set back toFalse
. So you can use that to check the status of the timer.you can use this !!!!
Use the Enabled property:
The Enabled property tells you if the timer is running or not.
One line of code:
Assuming you're using the System.Timers.Timer class, simply use:
See the MSDN page for more handy methods!!