Dispatchertimer,向上计数,在文本框Windows Phone中以00:00:00格式显示
如何制作这样的格式hh:mm:ss? 我真的厌倦了把这个提起来:)我希望你能帮我个忙Dispatchertimer,向上计数,在文本框Windows Phone中以00:00:00格式显示,timer,textbox,count,Timer,Textbox,Count,如何制作这样的格式hh:mm:ss? 我真的厌倦了把这个提起来:)我希望你能帮我个忙 public void StartTimer() { System.Windows.Threading.DispatcherTimer myDispatcherTimer = new System.Windows.Threading.DispatcherTimer(); myDispatcherTimer.Interval = new TimeSpan(0, 0, 0,
public void StartTimer()
{
System.Windows.Threading.DispatcherTimer myDispatcherTimer = new System.Windows.Threading.DispatcherTimer();
myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100); // 100 Milliseconds
myDispatcherTimer.Tick += new EventHandler(Each_Tick);
myDispatcherTimer.Start();
}
int i = 0;
// Raised every 100 miliseconds while the DispatcherTimer is active.
public void Each_Tick(object o, EventArgs sender)
{
textBox2.Text = " " + i++.ToString();
}
首先,您需要使用上面创建的时间跨度。
只需像这样使用
string
格式化功能:
TimeSpan HundRepliec=新的时间跨度(0,0,0,0100)
希望这有帮助
textBox2.Text = string.Format(@"{0:hh\:mm\:ss}", hundredMilliSec);