问题
This is really confusing me.
All im trying to do is create a digital clock on a windows form, so i googled and tried this code but it refuses to show in the label.
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString("HH:mm:ss");
}
What am i doing wrong?
Thanks for all the help in advance
回答1:
You need to set timer1.Interval to a reasonable value, like 1000.
You also need to set timer1.Enabled = true;
Finally you need to make sure your event handler timer1_Tick
is connected to the timer1.Tick event of an existing timer.
来源:https://stackoverflow.com/questions/13344288/digital-clock-not-displaying