Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable Progress Bar?

Status
Not open for further replies.

Akusei

Programmer
Jul 15, 2003
90
US
Does anyone know a proven method or formula to have the Progress Bar smoothly go from 0% to 100% without knowing what the Maximum value is? Maybe some way of progressing from 0% to 100% over time... and the time would be variable. Does anyone know what I'm talking about?
 
I think these are contradictory requirements.

If whatever event you're tracking occurs slower than real time, then the progress bar would move in reverse. If it occurs at the same rate as real time passing, then the progress bar would stand still. Only if it occurs faster than the clock would the progress bar value actually increase.

What I've seen done is have the progress bar increase with your events, and when you get to 100%, start over again. That way the user gets some indication that something is happening.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
It sounds like you want a continuous 'activity' bar, such as the bar that loops when XP is booting up. It never actually signifies a value, just that something is happening.

I saw a sample control that did just that once, try Googling for 'activity bar' or similair.
 
Let me further explain...
If I don't know the exact number of operations, then what do I do? For instance.

Code:
pbar.Maximum = 3;
pbar.Value = 0;
pbar.Step = 1;

//do somthing
pbar.PerformStep();
//do somthing
pbar.PerformStep();
//do somthing
pbar.PerformStep();

//Now my operations jump from 3 to an unknown amount.
while (something)
{
   pbar.PerformStep();
}

Do you see what I'm getting at. I don't want the bar to get to 100 until the whole process is complete, and I don't want it to start at 0 again in the middle of something. The problem is that the bar does some funny things if you change .Maximum and .Step and .Value to different numbers during the progress. I was wondering if there was some formula or algorithm you can perform on .Maximum, .Step and .Value to keep the progress bar increasing at a visible rate and stop at "full" when complete. Do you see now?
 
The progress bar really wants you to set a maximum. It sounds like you don't have one, so you can't.

In that case, all you can do is show some sort of activity to the user so they know that something is going on. If you look at what Windows does during file copies -- it displays an AVI of a file floating over to a folder, over and over. When it finishes, the whole dialog goes away, and never really says "I'm done". The absence of the dialog is confirmation of the task being complete.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Ok, then let me ask this...

What if I do know how many operations it is and I can set the .Maximum to a value. The problem now is that almost 90% of all the "operations" are taking place inside 2 seperate classes and the Progress bar is on the Windows Form seperate from those 2 classes. How will I effectivly update the Progress Bar?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top