Progress bar step

A

Alan T

Sometimes I have to loop thru' 55 times, sometimes 240 times.

How do I set the Maximum and, Step property of progress bar so that it
reflects the progress inside the while loop?

i = 55;

for (int x= 0; x < i; x++)
{
.....
ProgressBar1.PerformStep().
}
 
D

Daniel

//doing property names from top of my head so use common sense and set to
what i obviously mean
// also i am assuming your step is set at 1

ProgressBar1.Max = 55;

i = 55;

for (int x= 0; x < i; x++)
{
if(ProgressBar1.Value < ProgressBar1.Max)
ProgressBar1.PerformStep().
}

That would step by 1 every iteration and on the value equaling the max the
bar would stop.

Why are you doing it this way anyway? This just for testing it?

Remember fire your progress bar on a new thread to measure whatever it is
that is loading and so on so that it doesn't block your processing thread of
data that it is measuring.

Hope that helps, difficult to know how much use it is when the code above
would only be useful for testing and experimenting with how a progress bar
works.
 
A

Alan T

What I am doing is to process files in a directory as input parameter so the
number of files will be different depends on the directory.
I need to reflect the progress to the user of how many files have been
processed.
 
D

Daniel

I see

In that case you set the progressbar.max to how many files you are
expecting.
Set the stepvalue to 1

and then as you process each do the if statement i gave you before. Once you
process them all your prgressbar will be at 100%. Process file, update
progressbar etc until done
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top