【发布时间】:2008-10-28 01:27:51
【问题描述】:
当期望文化与 PC 中安装的文化不同时,如何在 .Net 中将国际化设置为 DateTimepicker 或 Calendar WinForm 控件?
【问题讨论】:
标签: c# .net internationalization datetimepicker culture
当期望文化与 PC 中安装的文化不同时,如何在 .Net 中将国际化设置为 DateTimepicker 或 Calendar WinForm 控件?
【问题讨论】:
标签: c# .net internationalization datetimepicker culture
似乎不可能改变文化。请参阅此KB article。
【讨论】:
基于之前的解决方案,我认为更好的是:
dateTimePicker.Format = DateTimePickerFormat.Custom;
dateTimePicker.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;
【讨论】:
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr");
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
【讨论】:
对于日期时间选择器
dtp.Format = DateTimePickerFormat.Custom;
dtp.CustomFormat = "yyyy-MM-dd"; // or the format you prefer
【讨论】:
我觉得有弯路。
代码
dateTimePicker.Format = DateTimePickerFormat.Custom;
string[] formats = dateTimePicker.Value.GetDateTimeFormats(Application.CurrentCulture);
dateTimePicker.CustomFormat = formats[0];
【讨论】:
使用 Telerik radDateTimePicker 并在 InitializeComponent() 之后编写此代码,并使用您的文化而不是“fa-IR”。
Application.CurrentCulture = new CultureInfo("fa-IR");
radDateTimePicker1.Format = DateTimePickerFormat.Custom;
radDateTimePicker1.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;
【讨论】: