C # Timing Control

3.15 Timing (Timer) Control
Timing Control (Timer), also known as a timer or a timer control, is periodically at regular intervals automatically trigger event
control. The program is running, the timing control is not visible.

Properties, methods and events 1. Timing control

? Property Interval: periodically automatically trigger event time interval, in milliseconds.

? Property Enabled: true, the timer is started. Call the method Start () also start the timer.

? Method Start () and Stop (): to start and stop the timer. Enabled = false set properties can stop the timer.

? Event Tick: every Interval property Interval specified time, an event is generated Tick.

4. Examples e3_9

Displays the current date and time using the label control

(1) the establishment of a new project. Timer component to form the discharge, Name property timer1.

(2) put a Label control to the Form, Name property to label1.

(3) the following handler for the form Load event of Form1 increase event:

void the Form1_Load Private (Object SENDER, System.EventArgs E)
{
the this .timer1.Interval = 100;
the this .timer1.Enabled = to true;
Label1.Text DateTime.Now.ToString = ();
}
(. 4) as a Tick event Timer1 increased event handler as follows:

void the timer1_Tick Private (Object SENDER, System.EventArgs E)
{
Label1.Text DateTime.Now.ToString = ();
}
(. 5) to build, run, position label control date and time. FIG operation effect as described above.

(6)

Guess you like

Origin www.cnblogs.com/liudongjun/p/12208567.html