代码之家  ›  专栏  ›  技术社区  ›  Oscar Cabrero

如何在.NET中将区域性更改为DateTimePicker或日历控件

  •  15
  • Oscar Cabrero  · 技术社区  · 17 年前

    如何将国际化设置为 DateTimepicker Calendar WinForm 当欲望文化与安装在PC中的文化不同时在.NET中进行控制?

    5 回复  |  直到 8 年前
        1
  •  9
  •   Jonas Lincoln    17 年前

    似乎不可能改变文化。看到这个 KB article .

        2
  •  4
  •   KaDim    16 年前

    基于之前的解决方案,我认为更好的是:

    dateTimePicker.Format = DateTimePickerFormat.Custom;
    dateTimePicker.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;
    
        3
  •  0
  •   Bigballs    17 年前
    System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr");
    System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
    
        4
  •  -1
  •   Hapkido    17 年前

    用于日期时间选取器

    dtp.Format = DateTimePickerFormat.Custom;
    dtp.CustomFormat = "yyyy-MM-dd"; // or the format you prefer
    
        5
  •  -1
  •   heejong    16 年前

    我想有绕道。

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

      dateTimePicker.Format = DateTimePickerFormat.Custom;
      string[] formats = dateTimePicker.Value.GetDateTimeFormats(Application.CurrentCulture);
      dateTimePicker.CustomFormat = formats[0];