问题描述
|
我正在用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时,图片发生变化,标签也发生变化。
解决方法
最简单的方法是使用
System.Windows.Forms.Timer
组件并处理Timer.Tick
事件:
private void timer1_Tick(object sender,EventArgs e)
{
progressBar1.PerformStep();
if (progressBar1.Value == 500)
{
// do whatever you want
}
}