Click here to Skip to main content
15,885,823 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
I have a radio button on a form (C++/CLI .NET) created using the form designer.

But in certain circumstance I want to change its associated text.

Simply assigning the new string to the ->Text property has no impact.

I tried things like Invalidate and Update to regenerate the control. They did not help.
Posted
Comments
ManavGuru 4-Jan-12 23:56pm    
can you wright code. i mean what are you doing in your code.
Sergey Alexandrovich Kryukov 5-Jan-12 0:04am    
First of all, tag it properly: WinForms. You really want people to see what UI library, technology, type of application, language do you use, before opening this page.
--SA

Please provide the code, wondering why its not working;
try it on click event..
C#
private void button1_Click(object sender, EventArgs e)
        {
       
            radioButton1.Text = textBox1.Text;
        }
 
Share this answer
 
Comments
Ger Hayden 5-Jan-12 14:40pm    
<pre> radioButton1->Text = L"New Text";</pre>
is not working.
the debugger shows it successfully assigned, but the form still shows the original value
Chetan Ghorley 6-Jan-12 19:53pm    
You might be doing something wrong. try rebuilding the code .
No invalidation is needed. Do you think the author of the property Text is an idiot? Of course the client area of a radio button is invalidated when a new value (different from the previous one) is assigned to the property; this is done via the property setter.

I don't know the exact reason of you observation that "assigning the new string to the ->Text property has no impact", but I'm certain it must be your mistake. There can be different reasons: the new value is not really new, the assignment operator is actually not called, UI is hanging by some reason, etc. You can easily run your code under Debugger to see what's going on. Actually, you should do it before asking a question like that, very likely — instead of asking the question. :-)

Do you homework in order to succeed.

—SA
 
Share this answer
 
Comments
Ger Hayden 5-Jan-12 14:35pm    
Heres the code
<pre> myRadioButton->Text = L"New Text";</pre>
The debugger shows the new value successfully assigned, but the form still shows the original value.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900