943,671 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 5266
  • C# RSS
Apr 9th, 2009
0

Label not updating

Expand Post »
Hey guys,

I've got a multithreaded application done in C# but the label on one of my forms won't update! It doesn't do anything

C# Syntax (Toggle Plain Text)
  1.  
  2. public IndividualPCSpec(AllKnownDevicesFrm parent)
  3. {
  4. m_Parent = parent;
  5. InitializeComponent();
  6. m_IPAddressLbl.Text = "HELLO";
  7. }
  8.  
  9. public void showInformation(ComputerHardware dto)
  10. {
  11.  
  12. m_IPAddressLbl.Text = "HELLO WORLD";
  13. this.Refresh();
  14. this.m_IPAddressLbl.Refresh();
  15.  
  16. Application.DoEvents();
  17. }

I don't get why.... it doesn't even get set to "Hello"
Similar Threads
Reputation Points: 12
Solved Threads: 5
Posting Pro
Acidburn is offline Offline
510 posts
since Dec 2004
Apr 9th, 2009
0

Re: Label not updating

How are you calling this functions?
Reputation Points: 231
Solved Threads: 12
Junior Poster
thoughtcoder is offline Offline
139 posts
since Mar 2009
Apr 9th, 2009
0

Re: Label not updating

from another class.

C# Syntax (Toggle Plain Text)
  1. Class X
  2. IndividualPCSpec m_individualPC = new IndividualPCSpec (this);
  3. ComputerHardware dto = new ComputerHardware(...);
  4. ..
  5. ..
  6. Function X()
  7. {
  8. showInformation(dto);
  9. }
  10. }
Reputation Points: 12
Solved Threads: 5
Posting Pro
Acidburn is offline Offline
510 posts
since Dec 2004
Apr 9th, 2009
0

Re: Label not updating

If you attach a debugger, does it show the line m_IPAddressLbl.Text = "HELLO WORLD"; running?
Reputation Points: 231
Solved Threads: 12
Junior Poster
thoughtcoder is offline Offline
139 posts
since Mar 2009
Apr 9th, 2009
0

Re: Label not updating

Normally updating labels in a form is not a thread-safe operation. Check this article out:

http://msdn.microsoft.com/en-us/libr...28(VS.80).aspx

That may give you a good idea of what you have to do to update the label. You need to invoke another method to update the label's text. I'm surprised an exception is not being thrown...
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: problem transfering data from one form to another
Next Thread in C# Forum Timeline: Trouble with dataGridViewButtonColumn event





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC