Good evening. I make an application on windows forms (.NET Framework 4.6). It is necessary to make localization. Depending on the selected language, I connect the corresponding resource file. Made a change of language, but only when the form is restarted. And when you restart, the data entered is reset. How can I make a language change without restarting the form? Could you give a little example in C ++?
- You will need to update all controls. - MihailPw
- Oh, switch language on the fly in WinForms? This, as I understand it, is quite a big and painful problem. I'm afraid a small simple solution will not work, it will be a big and difficult one. - VladD
- one@ AGS17: And if the text in the control came from the code-behind? - VladD
|
1 answer
- Try to run all controls on the form and save the data. After changing the language, restore this data.
You can set the text for the Label directly from the code, like this:
ResourceManager LocRM = new ResourceManager ("WindowsApplication1.WinFormStrings", typeof (Form1) .Assembly); label1.text = LocRM.GetString ("strMessage");
Then you can simply run a method that updates the labels after changing the language. If the controls on the form are few, then this is the best way.
|