Pergunta

I have this code in a method and the method i call it in a timer1 tick event that it's interval set to 1000ms.

counter += 1;
progressBar1.Value = counter * 10;
label9.Text = counter.ToString();
label9.Visible = true;
if (counter == 10)

Now it's updating every 10 seconds so it's working good the progressBar value is jump each 10% untill 100%. Buw now i want to change and check for 60 seocnds:

if (counter == 60)

Now what the progressBar1.Value should be ?

progressBar1.Value = counter * 10;

Instead * 10 what it should be ?

Foi útil?

Solução

Set the Maximum property of the ProgressBar:

Gets or sets the maximum value of the range of the control. The default is 100.

So in your original code, you could do:

p.Maximum = 10;

counter += 1;
progressBar1.Value = counter;
label9.Text = counter.ToString();
label9.Visible = true;

if (counter == 10)

And in your updated code, change the Maximum to 60 and keep (almost) everything else the same:

p.Maximum = 60;

counter += 1;
progressBar1.Value = counter;
label9.Text = counter.ToString();
label9.Visible = true;

if (counter == 60)
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top