I wrote a window UI by c++ windows form. I'd like to create a string table to localize the Form. My steps are:
1. I set the form localizable=true.
2. Add a new .resx file named (project name).en-US.resx and edit the string table.
3. Set the text of components using the code like this->button1->Text = resources->GetString("CLOSE");
After I finish setting the text, I build the project and execute it, the button truly show the text. But if I modify the UI(like add component or change the position of the button), the text will disappear after I build again. What's wrong with the code? How can the text always show? Otherwise I need to set again if I modify the form><. Thanks for anybody's help.
0
votes
1 Answers
0
votes
Do not make changes to the code that is generated by the designer. Anything inside the InitializeComponent() method. Such changes will disappear when you make another change in the designer and it re-generates the method. Code in the constructor is okay, put it after the InitializeComponent() call.
The better procedure to localize a form is to let the designer generate the .resx file and the code. Change the form's Language property to the desired language, then change the Text property in the property grid. No additional code is required.