当手表正在运行时,是否可以实现一个秒表,显示标签上的秒表值会发生变化。
我使用以下代码
添加了秒表Stopwatch stopwatch = new Stopwatch();
// Begin timing
stopwatch.Start();
// Stop timing
stopwatch.Stop();
我应该如何在标签上显示时间????
答案 0 :(得分:2)
// create a timer that fires every 10 ms
Timer aTimer = new Timer(10);
// Hook up the Elapsed event for the timer.
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
aTimer.Enabled = true;
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
// update your label here
}