如何使用 c# 在标签上将更新时间显示为系统时间? [英] How to display updated time as system time on a label using c#?

查看:34
本文介绍了如何使用 c# 在标签上将更新时间显示为系统时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I want to display current time on a label using C# but time will continuously change as system time changes. How can I do this?

解决方案

Add a new Timer control to your form, called Timer1, set interval to 1000 (ms), then double click on the Timer control to edit the code-behind for Timer1_Tick and add this code:

this.label1.Text = DateTime.Now.ToString();

这篇关于如何使用 c# 在标签上将更新时间显示为系统时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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