I want the text in a textbox "txtConvertedInches" to be selected when i press the radio button "rbFromInches".

private: System::Void rbFromInches_CheckedChanged(System::Object^  sender, System::EventArgs^  e) {
             bConvertingToInches = !rbFromInches->Checked;
             ToggleControls();
             txtConvertedInches->SelectAll(); //I thought this would do it, but nothing happens
         }

Recommended Answers

All 3 Replies

This is not C++. What are the '^' tokens doing in the argument list? Also, is rbFromInches->Checked a member variable, or a method. You are using it as a variable. Finally, this is not enough code and context to know what you are doing. :-(

try
txtConvertedInches->Focus
this should set focus to the textbox
Cheers Milton

Worked perfect, Milton. Thanks!

And rubberman, I am using Visual C++ Express 2010. I thought for sure that would be C++?
And this

private: System::Void rbFromInches_CheckedChanged(System::Object^  sender, System::EventArgs^  e)

is what gets written when i double click the radio button, in a Windows Forms Application.
What i've done is i've been following a tutorial for Visual C++ Express on youtube, and after 8 videos or so i ended up with a feet and inches converter. It converts both from "feet and inches" to "inches", and from "inches" to "feet and inches", depending on which radio button is checked. The only thing that didnt work as i wanted it to in that block of code, was "txtConvertedInches->SelectAll();". But "txtConvertedInches->Focus();" work perfectly.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.