Progress Bar That Changes Text And Pictures
开发者_StackOverflow中文版I am making a project in C#. I am trying to get a label and a picture to change when the progress bar reaches a certain point. The step is 10 and the maximum is 5000. So far I have this
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";
// ...
What I am trying to do is when it reaches 500, for the picture to change and the label to change also.
The easiest way would be to use a System.Windows.Forms.Timer
component, and handle the Timer.Tick
event:
private void timer1_Tick(object sender, EventArgs e)
{
progressBar1.PerformStep();
if (progressBar1.Value == 500)
{
// do whatever you want
}
}
精彩评论