Reputation: 757
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 the current date and time. thanks....
By the way its a windows form and I am using visual studio 2010
Upvotes: 0
Views: 3523
Reputation: 765
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
Upvotes: 1
Reputation: 2108
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
Upvotes: 6