|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
||||
|
||||
|
Did you add an EventHandler delegate pointing to your handler method to the Button's Click event?
|
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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? |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
||||
|
||||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > .Net Development > Dynamic label in Form |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|