秒表显示经过时间的计数器? [英] StopWatch to Show Counter of Elapsed Time?
本文介绍了秒表显示经过时间的计数器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的 Windows 窗体上有一个文本框,我想显示我的程序所花费的时间,但我没有在文本框中看到任何时间计数.下面是我的代码
I have a textbox on my windows form that I am wanting to show the elapsed time that my procedure has taken, but I am not seeing any time counting in the textbox. Below is my code
public partial class Form1 : System.Windows.Forms.Form
{
private Stopwatch watch = new Stopwatch()l
private void btn_RashadSL()
{
watch.Start();
//lots of code here that typically takes around 15 - 20 minutes to complete
}
private void timer_Tick(object sender, EventArgs e)
{
textbox1.Text = watch.Elapsed.Seconds.ToString();
}
}
推荐答案
鉴于您发布的代码,我认为问题在于您从未设置过计时器来实际调用 timer_Tick代码>方法.
Given the code you have posted I'd say the problem is that at no point have you set up a timer to actually call the timer_Tick
method.
这篇关于秒表显示经过时间的计数器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文