gpt4 book ai didi

c# - 我想每秒显示数字时钟来刷新TextBox(Windows App)

转载 作者:太空宇宙 更新时间:2023-11-03 18:11:12 25 4
gpt4 key购买 nike

C#代码

TextTime.Text = DateTime.Now.ToString();


要每秒刷新一次此文本框

或向数字钟展示任何创意

最佳答案

最简单的方法是将计时器添加到您的应用中,然后如下所示进行操作:



表格加载:

private void Form1_Load(object sender, EventArgs e) {
txtdate.Text = DateTime.Now.ToString(("dddd" + ("," + "MM-dd-yyyy")));
Timer1.Interval = 1000;
Timer1.Enabled = true;
}


计时器滴答:

private void Timer1_Tick(object sender, EventArgs e) {
txtTime.Text = DateTime.Now.ToString("HH:mm:ss");
}

关于c# - 我想每秒显示数字时钟来刷新TextBox(Windows App),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14923621/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com