c# - Runnings time in seconds in a Label -
i show current time in label. time should updated in realtime.
currently do:
txtdatetime.text = datetime.now.tolocaltime().tostring();
edit i'm using visual studio 2017 .net framework portable class library develop crossplatform mobile application.
sorry if unclear in making question
use timer
, update label every second:
// declare timer field prevent garbage collection timer t = new timer(); // set values , event handler in form load (or similar) t.interval = 1000; t.tick += (x,y) => { txtdatetime.text = datetime.now.tolocaltime().tostring(); }; t.start();
Comments
Post a Comment