Refresh current form to reflect culture change

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everybody,

I want to add localization support into my windows forms application.
Basically, I create a menu item where users can choose a language of their
choice. When users choose their preferred language, I want to update all the
texts/labels on the current form UI to the new culture, instantaneously.

For this, I have created a .resx file for each supported culture and in the
event handlers for menu item's Click event, I change the CurrentUICulture
property to the corresponding culture as follow:

System.Threading.Thread.CurrentThread.CurrentUICulture = new
System.Globalization.CultureInfo("en-US");

However, when the program runs, nothing happens. So, I guess I must somehow
force the form to reload itself. I've tried all the methods like
Form.Update(), Form.Refresh(), Form.Invalidate(), ... but unsuccessful so
far.

Does anybody know the solution to this scenario ?

Thanks a lot

SuperKinhLuan
 
Two solutions,

1. Either instead of relying on framework support for localization,
manually load strings from the .resx files based on the culture settings.

2. If possible after changing the threads UI culture create a new
instance of the form which you want to display and then show that. Of
course for the form in which the user is changing the culture you would
still have to do the string changing manually.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph
 
Back
Top