public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
timer1.Interval = 1000; //這樣的用法會每 1 秒跑去 檢查條件
timer1.Start(); //開始跑
//timer1.Stop();
}
//由於 timer1.Interval = 1000 (1秒),所以每1秒會執行一次 Timer_Tick
private void timer1_Tick(object sender, EventArgs e)
{
DateTime qq = new DateTime();
//顯示現在日期、時間、秒數....
label6.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
This is a good example of Timer C#
回覆刪除