Re: SV: Updating status label and status bar

Tech-Archive recommends: Fix windows errors by optimizing your registry



On Sun, 17 Feb 2008 11:28:10 -0800, K Viltersten <tmp1@xxxxxxxxxxxxxx> wrote:

I added a status label and a status bar and as the status reaches its maximum the text on the label will change. The
problem is that the text changes BEFORE
the bar gets "pumped up" to the max.
When you write "status bar", do you really mean the ProgressBar class?

Yes. My bad. I'm referring to a green bar at the bottom of the screen, right on an instance of the ToolsStrip class.

As far as your specific question goes, the code snippet you posted should, assuming the rest of the code doesn't do anything odd, do exactly what you'd expect: set the text to "Done." at the same time that the progress bar reaches its maximum value.

After an investigation i learned that the animated move of the bar
starts and WHILE it's being "pumped-up", (in its own thread, i'd
guess), the program continues updating the label. So, odd - no.
But sure ugly and inconvienient...

Okay, that makes sense. I haven't used ProgressBar enough to know the specifics, but from your description it seems reasonable to believe that it animates between settings. I'd never noticed that before, even when the value changes dramatically, but I may just not have been paying attention.

I don't know if there's a way to bypass the behavior. I can think of an ugly hack though: create a different progress bar, already set to the maximum value, that remains hidden until the end. Then when you reach the end, swap it for the "live" one. :)

Personally, I'd live with the animation. But I know how it can feel sometimes when the GUI just isn't doing _exactly_ what you want it to.

If this isn't what you're seeing, then it seems likely that somewhere in the rest of the code is something that does something odd, resulting in the text being updated before the progress bar is.

I've tested creating a new, standard project with only this bar being "pumped-up" as a single button is being pressed. Not
much of other code to interviene there.

Okay. That's why I wrote "likely" as opposed to "must be". :)

However, since you didn't post a concise-but-complete sample of code that reliably demonstrates the problem, it's not nearly as likely that anyone can answer your question.

You surely don't refer to all the code being created, do you? VS
created at least three files for me, this far, i think. Did i misunderstand something?

The minimal VS Designer template is generally Program.cs, Form1.cs, and Form1.Designer.cs, yes. In the simplest cases, sometimes you can post only the code in Form1.cs, as long as everything else is obvious. This is in fact worth a first try, usually, since it produces the least amount of posted code.

But yes, if you want people to be able to actually execute the same exact code you're executing and thus help you work through what's going on, you need to post everything.

Note that you can take those three files and merge them into a single one (editing to remove extra "using" namespace declarations and breaks between the "partial" Form1 class, of course, so that it call compiles). A person won't be able to modify something like that in the designer, but it's easier to get it up and working to start with and otherwise is just as helpful.

Pete
.


Quantcast