Digital clock not displaying

给你一囗甜甜゛ 提交于 2019-12-11 20:23:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!