Question

In a .net 2 winforms application, what's a good way to set the culture for the entire application?
Setting CurrentThread.CurrentCulture for every new thread is repetitive and error-prone.
Ideally I'd like to set it when the app starts and forget about it.

Was it helpful?

Solution

The culture for a thread in .NET is the culture for the system (as viewed by a single application/process). There is no way to override that in .NET, you'll have to continue setting the CurrentCulture for each new thread.

OTHER TIPS

You can set application current culture this way:

static void Main()
{
    System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("fi-FI");
    Application.CurrentCulture = cultureInfo;
    Application.EnableVisualStyles();
    Application.SetCompatibleTextRenderingDefault(false);
    Application.Run(new Form1());
}

I'm not sure if it helps, because I have never tested it with threads.

edit: it doesn't work. I think you have to set current culture in every thread.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top