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.
views:
2108answers:
2
+3
A:
The culture for a thread in .NET is the culture for the system. There is no way to override that in .NET, you'll have to continue setting the CurrentCulture for each new thread.
Peter Ritchie
2008-09-18 15:08:02
> the culture for the systemstrictly speaking, the culture corresponding to the regional settings of the current user.
Joe
2008-09-18 16:11:08
A:
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.
Vertigo
2008-09-18 15:33:32
`Application.CurrentCulture` delegates to `Thread.CurrentThread.CurrentCulture` so it only sets it for the main thread of the application.
adrianbanks
2009-09-17 09:11:43