Search code examples
c#winformsencodingdesignervs-community-edition

How fix local language text encoding problems of winform controls


In windowsForm Designer, I placed a label on form. Wrote some Turkish characters for its text property. text > "Giriş" which means login.

When application is started, ş char is not displayed correct. Some kind of encoding problem

Windows10 has 2 language packs > English (US) and Turkish. English is default and current language used. I do not want to change text of design elements programmatically. I want to use the FormDesigner.

Here is what i see in Windows Form Designer

enter image description here

And here is what i see when running

enter image description here


Solution

  • You have to set both the CurrentCulture and CurrentUICulture as per Microsoft's example:

    // C#
    // Put the using statements at the beginning of the code module
    using System.Threading;  
    using System.Globalization;
    
    // Put the following code before InitializeComponent()
    // Sets the culture to French (France)
    Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
    
    // Sets the UI culture to French (France)
    Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
    

    You can set this once at application start-up.