我正在用C#制作一个项目。当进度条达到某一点时,我正在尝试更改标签和图片。步骤是10,最大值是5000.到目前为止我有这个
private void button3_Click(object sender, EventArgs e)
{
timer1.Start();
pictureBox2.Enabled = true;
pictureBox2.Visible = true;
label1.Text = "Scanning";
this.pictureBox4.Enabled = true;
this.pictureBox4.Visible = true;
this.pictureBox3.Enabled = false;
this.pictureBox3.Visible = false;
label1.Text = "Threat Detected";
// ...
我要做的是当它达到500时,图片要改变,标签也要改变。
答案 0 :(得分:2)
最简单的方法是使用System.Windows.Forms.Timer
组件,并处理Timer.Tick
事件:
private void timer1_Tick(object sender, EventArgs e)
{
progressBar1.PerformStep();
if (progressBar1.Value == 500)
{
// do whatever you want
}
}