Windows Develop Bookmark and Share   
 index > Windows Forms General > Stupid problem with a Label in a statusStrip
 

Stupid problem with a Label in a statusStrip

Hi, i have a label and a progress bar in a statuStrip in my RSS Reader application. I want that a message like "Update in progress" is displayed in the label during the update of the RSS feeds. So, before i start the update, i simply set:

statusLabel.Text="Update in progres..."

and, when the update is complete, i do:

statusLabel.Text="Done".

The problem is the message don't appear! I've tried to change the label text in other parts of the application, and it works. I've tried also to change the message "Done" with something else, and it displays it. But there is nothing to do, when i press the refresh button of my application, the label text still remains "Done".
What can i do? The progress bar near the label works perfectly too!
The crazy thing is that, if I add a watcher to statusLabel.Text during the debug, it says the its value is "Update in progress...", but on the screen i can only read "Done".
qmatteoq  Friday, August 18, 2006 11:20 PM
No problemo, call Refresh on the ToolStrip container:
ToolStripLabel1.Text = "Update in progress..."
ToolStrip1.Refresh()

nobugz  Saturday, August 19, 2006 11:10 AM
The label doesn't get a chance to repaint itself because your program is busy with the RSS update. You're not pumping messages so the WM_PAINT message doesn't get processed. The fix is simple:
label1.Text = "Update in progress...";
label1.Refresh();

nobugz  Saturday, August 19, 2006 12:05 AM
Ehm, i've tried to do as you said, but there is no method called "Refresh" for the label object... The problem is that it's a toolStripStatusLabel, so there isn't a Refresh method...
qmatteoq  Saturday, August 19, 2006 8:22 AM
No problemo, call Refresh on the ToolStrip container:
ToolStripLabel1.Text = "Update in progress..."
ToolStrip1.Refresh()

nobugz  Saturday, August 19, 2006 11:10 AM
Thanks very much for the help, it works perfectly now!
qmatteoq  Saturday, August 19, 2006 10:36 PM
Had the same problem, but that solved it. Thanks a lot!
Tormod  Thursday, July 19, 2007 10:45 AM

I have this same problem and calling Refresh on the status strip doesn't help. Has anyone seen this?

Is there any other way to handle this?

Thanks.

My code looks like this:

ToolStripStatusLabel1.Text = "Translating " & iFileCount & " of " & i_sFiles.Length & "."

StatusStrip1.Refresh()

Shoot_er  Tuesday, July 24, 2007 6:10 PM
Didn't work for me either. First time I set the text of the label control it comes through okay, but the second and subsequent times the text of the label appears to be blank. The progress bar on the same strip updates fine in response to the refresh or invalidate/update calls.

my code looks like this:

Code Snippet

this.btCreateCatalog_Click( sender, e );

HighPerformanceTimer overallTimer = new HighPerformanceTimer(),

scriptTimer = new HighPerformanceTimer();

if( this.catalog != null )

{

// get the set of upgrade scripts and run them one at a time

string[] upgradeScripts = Directory.GetFiles( this.catalog.CatalogDirectory, "Cube*.xml" );

string lastScript = null, message = null;

this.progressBar.Maximum = upgradeScripts.Length;

for( int i = 0; i < upgradeScripts.Length; i++ )

{

string script = File.ReadAllText( upgradeScripts[i] );

this.scriptEditBox.CodeText = script;

scriptTimer.Stop();

if( lastScript != null )

{

message = "Loaded '" + lastScript + "' in " + Convert.ToInt32( scriptTimer.ElapsedSeconds() ).ToString() + " seconds. ";

}

lastScript = upgradeScripts[i];

message += "Now loading '" + lastScript + "'.";

this.lbCurrentUpgradeScriptName.Text = message;

this.statusStrip.Refresh();

scriptTimer.Start();

this.UpgradeCatalog();

this.progressBar.Increment( 1 );

this.statusStrip.Refresh();

}

}

Massey  Thursday, June 05, 2008 1:49 AM

You can use google to search for other answers

Custom Search

More Threads

• Crystal Report 9(CR) and visual basic.net window forms
• Proxy Settings
• Make sure no Duplicate forms open
• How to get the MainForm reference?
• What do I use instead of the OnCurrent event?
• Controls Not Appearing on Windows Form
• How to convert an object (custom object) into a byte [] array?
• Dynamic Application
• User Controls runtime error
• How to focus a text for mouse hover event?