C#如何获取动态的系统时间

来源:互联网 发布:php表白源码 编辑:程序博客网 时间:2024/05/17 01:01
private void Form1_Load(object sender, EventArgs e) //首先在主窗体添加定时事件{            this.timer1.Interval = 1000;//设置定时器触发间隔            this.timer1.Start();    //启动定时器            label1.Text = DateTime.Now.ToString(); }

private void timer1_Tick(object sender, EventArgs e)    //接着在定时器触发事件中添加获取时间和显示时间函数{            DateTime time = DateTime.Now;       //获取当前时间            label1.Font = new Font("宋体",12);  //设置label1显示字体            this.label1.Text = time.ToString(); //显示当前时间} 

原创粉丝点击