如何设置国际化 DateTimepicker 或者 Calendar WinForm 当所需文化与 PC 中安装的文化不同时,如何在 .Net 中进行控制?

有帮助吗?

解决方案

似乎无法改变文化。请参阅此知识库文章

其他提示

根据之前的解决方案,我认为更好的是:

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;

对于DateTimePicker

dtp.Format = DateTimePickerFormat.Custom;
dtp.CustomFormat = "yyyy-MM-dd"; // or the format you prefer

我觉得还有弯路。

  1. 设置事件处理程序“ValueChanged”
  2. 代码

    dateTimePicker.Format = DateTimePickerFormat.Custom;
    string[] formats = dateTimePicker.Value.GetDateTimeFormats(Application.CurrentCulture);
    dateTimePicker.CustomFormat = formats[0];
    
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top