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

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -