【发布时间】:2018-09-17 08:10:32
【问题描述】:
我捕获了启动时间和当前时间,但我的问题是如果启动时间已经过去,标签不会改变。我需要重新打开我的 windows 窗体 (c#) 以便标签会改变。
代码:
_hh = DateTime.Now.Hour;
_min = DateTime.Now.Minute;
_yy = DateTime.Now.Year;
_mm = DateTime.Now.Month;
_dd = DateTime.Now.Day;
DateTime _original_launch_time = new DateTime(_yy, _mm, _dd, 13, 0, 0);//this is the default time for launch
DateTime time = new DateTime(_yy, _mm, _dd, _hh, _min, 0); //this gets the current time
if (_original_launch_time > time)
{
label1.Text = "your not late";
}
else
{
label1.Text = "your late";
}
【问题讨论】:
-
您是否在更新面板中获取了标签?
-
正如您目前所拥有的那样,如果当前时间在执行代码时的 1300 之前,您的代码会将
label1.Text设置为“您未迟到”...您能澄清一下您到底想要什么吗?做不同的事?如果需要在 1300 之后自动更新,例如需要把这段代码放在一个定时器滴答事件中。 -
在哪里可以找到更新面板?
标签: c# .net datetime label timespan