兰保明

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
 1 public partial class Timer : UserControl
2 {
3 public Timer()
4 {
5 // 为初始化变量所必需
6 InitializeComponent();
7 DispatcherTimer timer = new DispatcherTimer();
8 timer.Interval = new TimeSpan(0, 0, 1);
9 timer.Tick += new EventHandler(timer_Tick);
10 timer.Start();
11 }
12
13 void timer_Tick(object sender, EventArgs e)
14 {
15 tbkTimer.Text = "当前时间:" + DateTime.Now.ToLongTimeString();
16 }
17 }
posted on 2011-07-21 09:17  兰保明  阅读(846)  评论(0编辑  收藏  举报