label update/get system time
-
i want a label to show the current system time? is there a method/property i can use to get the system time??
rzvme
DateTime.Now
SkyWalker
-
i want a label to show the current system time? is there a method/property i can use to get the system time??
rzvme
-
i want a label to show the current system time? is there a method/property i can use to get the system time??
rzvme
you can use System.DateTime.Now
-
i want a label to show the current system time? is there a method/property i can use to get the system time??
rzvme
-
i want a label to show the current system time? is there a method/property i can use to get the system time??
rzvme
As already suggested you can use
DateTime.Now.ToString(...formatting options...)
to assign a value to the label. However this will only assigned the date time when the code is actually executed. I read your post as wanting it to display the current time. IMHO I would create a timer that ticks every second (or minute depending on what your clock displays) the tick event would then update the label value with the newDateTime.Now
-
Call this
lblTime.Text=DateTime.Now.ToString();
in a loop.V. I found a living worth working for, but haven't found work worth living for.
Use 100% of CPU to change a string every second or so ? I would rather recommend a System.Windows.Forms.Timer to periodically update the label... :)
Luc Pattyn
-
Use 100% of CPU to change a string every second or so ? I would rather recommend a System.Windows.Forms.Timer to periodically update the label... :)
Luc Pattyn
As a matter of fact, that was what I had in mind, but I didn't feel like explaining Timers... :-D.
V.
Stop smoking so you can: Enjoy longer the money you save. Moviereview Archive