| 发表于:2007-02-14 23:30:05 楼主 |
我简单定义了一个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; } |
|
|
|
|