Home > Net >  C # form how to set up a one button to start and end events
C # form how to set up a one button to start and end events

Time:09-28

Set a button, click start events, events have a timer process, at the end of the click event timer when the very end

CodePudding user response:

Set a timer to control the global

CodePudding user response:

The timer Enabled=! The timer. Enabled

CodePudding user response:




refer to the second floor FainSheeg response:
timer. The Enabled=! The timer. Enabled

Positive solution # 2, this is a very classical writing,

CodePudding user response:

Can write a simple, give me have a look? I don't know the timer enabled=! Where the timer. Enabled?
If use the if (), parentheses inside what to write... -wuwuwu......

CodePudding user response:


The namespace button incompatible
{
Public partial class Form1: Form
{
Public _click ()
{
InitializeComponent ();
}
Bool star=false;
Private void button1_Click (object sender, EventArgs e)
{
Star=! Star;
If (star)
{
Enclosing timer1. Interval=500;
This. The timer1. Enabled=true;
This. For. Text="stop for current time";
}
The else
{
This. The timer1. Enabled=false;
This. For. Text="for current time";
}


}

Private void timer1_Tick (object sender, EventArgs e)
{
This. Label1. Text=DateTime. Now. The ToString ();

}
}
}

CodePudding user response:

A property of Running a stopwatch
  •  Tags:  
  • C#
  • Related