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?
Asked
Active
Viewed 4.5k times
15
shA.t
- 15,232
- 5
- 47
- 95
Oscar Cabrero
- 4,160
- 7
- 27
- 49
6 Answers
9
It doesn't seem to be possible to change the culture. See this KB article.
Jonas Lincoln
- 9,157
- 9
- 33
- 47
-
1Link to KB article is dead... :( They should've fixed it by now... it's 8 years later... – Teysz Nov 17 '16 at 12:56
-
Both these links are down now – derekantrican Nov 13 '19 at 14:31
5
Based on previous solution, I think the better is:
dateTimePicker.Format = DateTimePickerFormat.Custom;
dateTimePicker.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;
KaDim
- 51
- 1
- 1
0
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr");
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
Bigballs
- 3,361
- 9
- 28
- 27
-
4That 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 Dobrilovic Jun 08 '09 at 12:37
-1
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
- 696
- 7
- 7
-
1GetDateTimeFormats() does not produce format strings (that can be used to do formatting), but formatted strings (the result of formatting). Assigning such a string to .CustomFormat makes no sense. Would vote down answer, but lacking reputation myself... – Peter B Jul 29 '14 at 14:51
-1
For DateTimePicker
dtp.Format = DateTimePickerFormat.Custom;
dtp.CustomFormat = "yyyy-MM-dd"; // or the format you prefer
Hapkido
- 1,171
- 1
- 7
- 13
-
3Setting 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 Oct 28 '08 at 02:56
-
1Format 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 Dobrilovic Jun 08 '09 at 12:34
-1
Use the telerik radDateTimePicker and write this code , after InitializeComponent(), and Instead of "fa-IR" use your culture.
Application.CurrentCulture = new CultureInfo("fa-IR");
radDateTimePicker1.Format = DateTimePickerFormat.Custom;
radDateTimePicker1.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;
borchvm
- 2,729
- 7
- 34
- 36