Visual C#/WinForms Date and Time
Hello I want to create a clock in visual c#. Ive tried using the date time picker.
Yea. It gets the current time. But I want to have it auto updated just like a real clock so that the user can have a guide of 开发者_JAVA技巧the current date and time. thanks....
By the way its a windows form and I am using visual studio 2010
You should use "Timer" and do some operations to refresh time. You can get more info here: http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx
whit the timer you can do this.
private void Form1_Load(object sender, EventArgs e)
{
this.timer1.Interval = 1000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.label1.Text = DateTime.Now.ToString("HH:mm:ss");
}
Regards
精彩评论