关于timer
我简单定义了一个label,定义了一个timer,想通过Tick事件显示当间时间,设置了interval为1000了,但是没有显示出时间出来.请问一下哪儿还需要改动
private void Clock_Tick(object sender, System.EventArgs e)
{
int y,mo,d,h,m,s;
string temptime,strtime,hs,ms,ss;
y=DateTime.Now.Year;
mo=DateTime.Now.Month;
d=DateTime.Now.Day;
h = DateTime.Now .Hour;
m = DateTime.Now .Minute;
s = DateTime.Now .Second;
if(m <10)
ms= "0 "+m.ToString ();
else
ms=m.ToString ();
if(s <10)
ss= "0 "+s.ToString ();
else
ss=s.ToString ();
if(h <10)
hs = "0 "+h.ToString ();
else
hs = h.ToString ();
strtime=y.ToString()+ "年 "+m.ToString()+ "月 "+d.ToString()+ "日 ";
temptime = hs + ": " + ms + ": " + ss;
this.label1.Text=strtime+ " "+temptime;
}
------解决方案--------------------有没有timer.start()?