Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++/CLI C#
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 4-Jan-12 17:50pm
Ger Hayden24.1K
Comments
ManavGuru at 4-Jan-12 23:56pm
   
can you wright code. i mean what are you doing in your code.
SAKryukov at 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
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Please provide the code, wondering why its not working;
try it on click event..
private void button1_Click(object sender, EventArgs e)
        {
       
            radioButton1.Text = textBox1.Text;
        }
  Permalink  
Comments
Ger Hayden at 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 at 6-Jan-12 19:53pm
   
You might be doing something wrong. try rebuilding the code .
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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. Smile | :)
 
Do you homework in order to succeed.
 
—SA
  Permalink  
Comments
Ger Hayden at 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)

  Print Answers RSS
0 OriginalGriff 540
1 Sergey Alexandrovich Kryukov 426
2 Yogesh Kumar Tyagi 384
3 Prakriti Goyal 280
4 Maciej Los 205
0 OriginalGriff 6,472
1 Sergey Alexandrovich Kryukov 5,404
2 Maciej Los 3,434
3 Peter Leow 3,259
4 DamithSL 2,495


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 5 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100