表示不会用C#中自带的计时器控件,求高手 private void timer1_Tick(object sender, EventArgs e) { dateTimePicker1.Format = DateTimePickerFormat.Time; labtime.Text = dateTimePicker1.Text; } 是该写个死... 表示不会用C#中自带的计时器控件,求高手
private void timer1_Tick(object sender, EventArgs e)
{
dateTimePicker1.Format = DateTimePickerFormat.Time;
labtime.Text = dateTimePicker1.Text;
}
是该写个死循环,让他无限执行,还是有专门的设置?
没搞清timer原理吗?
是这样的
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
timer1.Interval = 1000;//设置timer计时器间隔,1000毫秒即1秒
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString();//获取系统时间赋给label1
}
//窗口加载时计时器开始工作
private void Form1_Load(object sender, EventArgs e)
{
timer1.Start();
}
}