我是 C# 新手,我已经搜索过但没有找到解决问题的简单方法。我正在创建一个 Windows 窗体应用程序。单击开始按钮后,它会每毫秒计数一次,当它从数组中达到特定值时会更改标签。毫秒是如何计算的?
-------------------------
AlekZanDer 代码:
namespace timer_simple3
{
public partial class Form1 : Form
{
long result = 0;
public Form1()
{
InitializeComponent();
this.timer1 = new System.Windows.Forms.Timer(this.components);
}
private void Form1_Load(object sender, EventArgs e)
{
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
}
private void timer1_Tick(object sender, EventArgs e)
{
result = result + 1;
label1.Text = Convert.ToString(result);
}
private void btstart_Click(object sender, EventArgs e)
{
timer1.Interval = 1; //you can also set this in the
//properties tab
timer1.Enabled = true;
timer1.Start();
// label1.Text = Convert.ToString(timer1);
}
private void btstop_Click(object sender, EventArgs e)
{
timer1.Stop();
}
}
}