秒表显示经过时间的计数器?

时间:2015-03-28 14:27:19

标签: c# winforms timer

我的Windows窗体上有一个文本框,我希望显示我的程序所用的已用时间,但我没有看到任何时间在文本框中计数。以下是我的代码

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();
  }
}

1 个答案:

答案 0 :(得分:1)

考虑到您发布的代码,我会说问题是您没有设置计时器来实际调用timer_Tick方法。

相关问题