Localization in C#

S

SDK

Hello,

I've written a little program in C# to test localization. It's one form
with a label and a button. I've included two languages into my form (Dutch
and English) using localization. In the main function, the culture is set
to dutch, and it all looks fine. But when I change the culture (by pressing
the button), I get a mix of the english resx and the dutch resx. My button
gets duplicated instead of moved, and my label keeps showing the dutch text
instead of the english one. When I show a messagebox with the contents of
my label, the English text is shown ?!

This is the code executed when the button is pressed:

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

So my question is:
Can I change the culture at runtime and expect an emmediate change on the
form. By executing a refresh method for instance. What am I doing wrong?

Remark:
It works fine when I change the culture and open a new form.


Thanks for your help...
 
G

Guest

When you call InitializeComponent(), you're adding all the controls to the
form. Unless you've previously removed all the controls from the form,
you'll get duplicates. Really, it's best to close the form and re-open it,
but you can also simply remove all the controls from the form and ten call
InitializeComponent().

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top