Question

I am working on c# winforms. I have taken MonthPicker control on windows form. I want to dispaly Thai Calendar regardless what culture is set on user's desktop machine as shown in below figure.

enter image description here

When user's machine culture is set to english it shows english calendar. when user's machine culture is set to thai it shows thai calendar. I want thai calendar in both the case.

I have tried with below line of code before InitializeComponent() but not getting desired output. Is there any mistak that I am doing or Is there any other way to achive the same?

system.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("th-TH");
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("th-TH");
Was it helpful?

Solution

While it is mentioned in an MS Support article regarding VS 2005 and .NET 2.0, you may be dealing with the same issue it describes:

This behavior occurs because the DateTimePicker control and the MonthCalendar control are Microsoft Windows common controls. Therefore, the operating system's user locale determines the user interface of these controls.

One way to check for this of course is to change your OS's user locale & see whether your MonthCalendar follows the change.

I do not know of a way to work around the MonthCalendar control's deference to the OS's user locale, but one possibility you might consider is an alternative, locale-aware calendar control.

For example, a locale-aware calendar control described on CodeProject sounds hopeful. 3rd-party (e.g. Telerik, Infragistics etcetera) calendar controls might also yield something.

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