Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update Window form UI after setting CurrentUICulture?

I tried to set CurrentUICulture of the application at run time. However, the menu items in my forms remained unchanged. Do I have to do something additional to changing CurrentUICulture?

like image 321
Varun Mahajan Avatar asked Jul 12 '11 08:07

Varun Mahajan


1 Answers

Late to the party again. But here's a solution I came up with:

public partial class MainForm : Form {

    public MainForm() {
        InitializeComponent();
    }

    private void mnuCultureEnglish_Click( object sender, EventArgs e ) {
        Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo( "en-US" );
        Controls.Clear();
        InitializeComponent();
    }

    private void mnuCultureGerman_Click( object sender, EventArgs e ) {
        Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo( "de-DE" );
        Controls.Clear();
        InitializeComponent();
    }
}
like image 101
Duncan Avatar answered Oct 18 '22 09:10

Duncan