using System;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Timer timer = new Timer();
timer.Interval = 1000; // 设置计时器间隔为1秒
timer.Tick += Timer_Tick; // 绑定Tick事件处理器
timer.Start(); // 启动计时器
}
private void Timer_Tick(object sender, EventArgs e)
{
lblCurrentTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); // 更新Label文本为当前时间
}
}
}
03-18
1432
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-18
507
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交