how to set internationalization to a DateTimepicker or Calendar WinForm control in .Net when the desire culture is different to the one installed in the PC?
A:
For DateTimePicker
dtp.Format = DateTimePickerFormat.Custom;
dtp.CustomFormat = "yyyy-MM-dd"; // or the format you prefer
Hapkido
2008-10-28 01:55:09
Setting the format is not the only thing controlled by the culture. It controls a lot of other things, such as whether the first day of the week is Sunday or Monday.
Kibbee
2008-10-28 02:56:49
Format is used only to show current date, but if you want to choose it, datetimepicker control will show full date, based on the regional settings.
Nenad
2009-06-08 12:34:33
+3
A:
It doesn't seem to be possible to change the culture. See this KB article.
Jonas Lincoln
2008-10-28 13:01:28
A:
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr");
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
Bigballs
2009-01-15 20:57:40
That will not change the regional settings of the Windows, only the current UI culture and current culture of the current thread (as the properties' names suggest). But DateTimePicker control looks only for the regional setting of the Windows, so it doesn't matter.
Nenad
2009-06-08 12:37:00
A:
I think there is detour.
- set event handler "ValueChanged"
code
dateTimePicker.Format = DateTimePickerFormat.Custom; string[] formats = dateTimePicker.Value.GetDateTimeFormats(Application.CurrentCulture); dateTimePicker.CustomFormat = formats[0];
heejong
2009-12-29 01:54:28
A:
Based on previous solution, I think the better is:
dateTimePicker.Format = DateTimePickerFormat.Custom;
dateTimePicker.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;
KaDim
2010-01-08 14:58:36