如何显示更新时间,系统时间使用C#的标签上? [英] How to display updated time as system time on a label using c#?
本文介绍了如何显示更新时间,系统时间使用C#的标签上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用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?
推荐答案
添加一个新的Timer控件到窗体中,所谓的定时器,设定的时间间隔为1000(毫秒),然后双击Timer控件编辑code-背后Timer1_Tick并添加此code:
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屋!
查看全文