Windows Develop Bookmark and Share   
 index > Windows Forms General > Updating a label
 

Updating a label

I have a Form with a label on it.  On the main form the Text of the label is set to "N/A" (not applicable).  When I start my program and kick off a thread, I want to update this label continuously when I choose with a time.  So it will count down like 60...59...58 etc.  I do this by using a callback function which updates the label by Label.Text = "60"; (or any possible string).  I can't figure out the EXACT behaviour, but sometimes the new label will leave some of the previous label showing.  i.e. since 60 is smaller than N/A, you can still see some of the A behind the "60". 

What can be done to remedy this?
  • Moved byTaylorMichaelLMVPTuesday, October 06, 2009 6:59 PMWinForms related (From:Visual C# General)
  •  
InformationCollector  Tuesday, October 06, 2009 6:28 PM
"I want to update this label continuously"
Don't do this and your issue will go away.  From the way I interpretted your scenario, your thread is constantly trying to update this value.  That means, every extra available ounce of resource power available to the process is being used to hit this method.  Set up a system based on a trigger and necessity and your problem will go away (say, a timer object that is invoked every 1000ms).
syntaxeater  Tuesday, October 06, 2009 6:34 PM
"I want to update this label continuously"
Don't do this and your issue will go away.  From the way I interpretted your scenario, your thread is constantly trying to update this value.  That means, every extra available ounce of resource power available to the process is being used to hit this method.  Set up a system based on a trigger and necessity and your problem will go away (say, a timer object that is invoked every 1000ms).

Ok bad description on my part, it actually only updates once every 30 second which is on a timer.
InformationCollector  Tuesday, October 06, 2009 6:45 PM
This smells like the typical painting problems you'll get when you don't use Control.Invoke().  If you have any assignment to Control.CheckForIllegalCrossThreadCalls in your program be sure to delete them.

Hans Passant.
nobugz  Tuesday, October 06, 2009 6:49 PM

You can use google to search for other answers

Custom Search

More Threads

• Items in ListView / ListBox change event does not exists
• how to achieve a new line character in XML
• Group policy
• detaching events
• Looking for a LOGIN form example
• Auto size modification from English to Chinese Windows.
• Terminal Services: Run Program at Logon. How to execute logoff command right away after program closed
• Change the system date and time settings using C#
• Arraylist populated using a custom class. Listbox Datasource set to the ArrayList. Error: Object must implement IConvertible
• Image list set by Win32 API calls for ListView