Nisar Afridi Nisar Afridi - 11 months ago 158
C# Question

Date Time Picker Culture info in Window Forms

My system language is Arabic, if I add

control on window form it shows Arabic months, and dates. I want to display it as English, so far I tried below methods but it is not working. Calendar control still show Arabic.

Value from DTP is saved as English format, but issue is the view of calendar control.

System.Threading.Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
dtpBTStartDate.Format = DateTimePickerFormat.Custom;
dtpBTStartDate.CustomFormat = Application.CurrentCulture.DateTimeFormat.LongDatePattern;

I tried to add thread method in Program.cs and also on form's Load , but still not working. Please advise?

Answer Source

Answer: If the OS UI language is Arabic I believe all DateTimePicker and MonthCalendar controls will be shown with Arabic UI, because those controls are just a wrapper around SysDateTimePick32 and SysMonthCal32.

Note: As an alternative you can use 3rd party libraries. The free open source FarsiLibrary is an option. While the library is called FarsiLibrary but its DateTimePicker and MonthView controls supports Jalali (Shamsi/Persian), Hijri (Qamari) and Gregorian calendars. Here is the link for codeproject article, page of the library in the author's site and the nuget package.