我正在尝试在进度条跟踪当前时间的同时进行 80 分钟的计时器滴答,但 C# Forms 中的进度条不会准确到计时器滴答。我将它设置为计时器每 1000 毫秒滴答一次,在该滴答声中,它将向进度条添加一个步骤。进度条不会像计时器一样起作用,有谁知道如何解决这个问题?
public Form1()
{
InitializeComponent();
initTimers();
}
public void timer1_Tick(object sender, EventArgs e)
{
progressBar1.Increment(1);
}
private void button1_Click(object sender, EventArgs e)
{
if (button1.Text == "Go")
{
timer1.Start();
button1.Text = "Stop";
}
else
{
timer1.Stop();
button1.Text = "Go";
}
}
public void initTimers()
{
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Interval = 1000;
}
public void progressTimers()
{
progressBar1.Value = 0;
progressBar1.Minimum = 0;
progressBar1.Maximum = 2;
progressBar1.Step = 1;
progressBar1.Visible = true;
}