.Net Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - More.Net Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old May 6th, 2008, 03:01 AM
naxatra naxatra is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 naxatra User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 31 sec
Reputation Power: 0
Dynamic label in Form

Hi All,
I am writing a c++.net application. I have a label on the form of the application and a button.
I want the label to change text when I click the button.But it doesnt happen.
In the handler function for the button,
I use the following line to change the text of the label:
this->label2->Text = L"5";
But there is no change.

Please help.I am new to c++.net

Thanks,
naxatra

Reply With Quote
  #2  
Old May 6th, 2008, 09:49 AM
LyonHaert's Avatar
LyonHaert LyonHaert is offline
Arcane Scribbler
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2005
Location: Indianapolis, IN
Posts: 1,610 LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 18 h 39 m 36 sec
Reputation Power: 379
Did you add an EventHandler delegate pointing to your handler method to the Button's Click event?
__________________
Joel B Fant - LyonHaert.net

2 + 2 is... 10... in base 4

Reply With Quote
  #3  
Old May 6th, 2008, 10:35 PM
naxatra naxatra is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 naxatra User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 31 sec
Reputation Power: 0
Thanks for replying.
Yes,there is a EventHandler delegate which invokes my handler function when the button is clicked.
The function does other stuff also in addition to trying to set the text of the label.
I am able to retrieve text of textbox and also retrieve the selected string from a combo box.But I am not able to change the text of the label.

I am not able to understand why it is not happening.

Thanks and regards,
naxatra

Reply With Quote
  #4  
Old May 7th, 2008, 10:08 AM
LyonHaert's Avatar
LyonHaert LyonHaert is offline
Arcane Scribbler
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2005
Location: Indianapolis, IN
Posts: 1,610 LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 18 h 39 m 36 sec
Reputation Power: 379
That's very odd. It should change. If it's not there is some other factor involved.

What value do you get when you retrieve the label2.Text right after setting it?

Reply With Quote
  #5  
Old May 7th, 2008, 10:33 PM
naxatra naxatra is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 3 naxatra User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 31 sec
Reputation Power: 0
Hi,
I found out the solution.I created a thread and dumped all other things the eventhandler was doing and kept the changing of text of the label in it.Now it is working.

The function was doing some heavy duty tasks like connecting to a server.So I guess,there were some high priority tasks which had to be taken care of and changing the text of the label got a low priority.

Thanks anyways,
naxatra

Reply With Quote
  #6  
Old May 8th, 2008, 09:49 AM
LyonHaert's Avatar
LyonHaert LyonHaert is offline
Arcane Scribbler
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jun 2005
Location: Indianapolis, IN
Posts: 1,610 LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level)LyonHaert User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 18 h 39 m 36 sec
Reputation Power: 379
Ahhh, I see. The intensive work was being done on the UI thread, so it blocked any other processing on the UI thread, preventing the controls from being redrawn.

You should also check out the BackgroundWorker component. It was specifically designed with this kind of situation in mind.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - More.Net Development > Dynamic label in Form


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway