private void Form1_Load(object sender, EventArgs e)
{
Timer timer = new Timer();
timer.Interval = 300;
timer.Enabled = true;
timer.Tick+=new EventHandler(timer_Tick);
}
private void timer_Tick(object sender, EventArgs e)
{
DateTime dt1 = Convert.ToDateTime("2015-05-10");
DateTime dt2 = DateTime.Now;
TimeSpan tm = dt1 - dt2;
this.label1.Text = "距离2015-05-10还剩" + tm.Days + "天" + tm.Hours + "时" + tm.Minutes + "分" + tm.Seconds + "秒";
}
新建个窗体名为Form1,在窗体上拖一个label控件名为label1,然后把这段代码复制进去,指定下load事件,运行看效果