0

是否可以实现一个秒表,在手表运行时显示标签上的秒表值变化。

我使用以下代码添加了秒表

Stopwatch stopwatch = new Stopwatch();
// Begin timing
stopwatch.Start();

// Stop timing
stopwatch.Stop();

我应该如何在标签上显示时间????

4

1 回答 1

2

使用Timer而不是Stopwatch

// 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
}
于 2013-03-29T21:17:33.477 回答