Use the following code before InitializeComponent() :
Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
In an ASP environment, you can use the Request.UserLanguages[0] as a language code to automatically select a language for users to select.
edit: If the form is already open, you will have to Dispose and reload it. Alternatively, you can use the following code, which is rather inconvenient:
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(MyFormClas)); this.myButton.Text = resources.GetString("myButton.Text"); this.myButton2.Text = resources.GetString("myButton2.Text"); ...
Depending on how you organized your ressource files, you can do this in a loop.
edti2: An alternative approach is to restart the application automatically. Depending on the application, this may not be acceptable.
if (MessageBox.Show(Resources.QWantToRestart, Resources.Warning, MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { System.Diagnostics.Process.Start(Application.ExecutablePath); System.Windows.Forms.Application.Exit(); }
edti3: what if you often see that the application tells the user to restart the application for the changed settings to take effect. this, combined with the second edit, is probably a way for many use cases.
source share