当欲望文化与PC中安装的文化不同时,如何将国际化设置为.Net中的DateTimepicker
或Calendar WinForm
控件?
答案 0 :(得分:9)
似乎无法改变文化。见KB article。
答案 1 :(得分:4)
根据之前的解决方案,我认为更好的是:
dateTimePicker.Format = DateTimePickerFormat.Custom;
dateTimePicker.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;
答案 2 :(得分:0)
System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr");
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
答案 3 :(得分:-1)
对于DateTimePicker
dtp.Format = DateTimePickerFormat.Custom;
dtp.CustomFormat = "yyyy-MM-dd"; // or the format you prefer
答案 4 :(得分:-1)
我认为有迂回。
码
dateTimePicker.Format = DateTimePickerFormat.Custom;
string[] formats = dateTimePicker.Value.GetDateTimeFormats(Application.CurrentCulture);
dateTimePicker.CustomFormat = formats[0];
答案 5 :(得分:-1)
使用telerik radDateTimePicker并在InitializeComponent()之后编写此代码,并使用您的区域性代替“ fa-IR”。
Application.CurrentCulture = new CultureInfo("fa-IR");
radDateTimePicker1.Format = DateTimePickerFormat.Custom;
radDateTimePicker1.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;