数字时钟不显示 [英] Digital clock not displaying

查看:241
本文介绍了数字时钟不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这真的让我感到困惑。

所有我想做的就是在Windows窗体上创建数字时钟,因此我用Google搜索并尝试了此代码,但它拒绝

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");
    }

我在做什么错了?

感谢您提前提供所有帮助

Thanks for all the help in advance

推荐答案

您需要设置 timer1.Interval 设置为合理的值,例如1000。

You need to set timer1.Interval to a reasonable value, like 1000.

您还需要设置 timer1.Enabled = true;

You also need to set timer1.Enabled = true;

最后,您需要确保事件处理程序 timer1_Tick 已连接到 timer1.Tick 现有计时器的事件。

Finally you need to make sure your event handler timer1_Tick is connected to the timer1.Tick event of an existing timer.

这篇关于数字时钟不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆