using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace xcu.WinformDemo
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.timer1.Enabled = true;//启动定时器
this.label1.Text = DateTime.Now.ToString(); //获取当前时间
}
private void timer1_Tick(object sender, EventArgs e)
{
this.label1.Text = DateTime.Now.ToString();
}
}
}
运行结果: