How to change culture to a DateTimepicker or calendar control in .Net

后端 未结 6 655
悲&欢浪女
悲&欢浪女 2020-12-05 14:59

How to set internationalization to a DateTimepicker or Calendar WinForm control in .Net when the desire culture is different to the one installed i

相关标签:
6条回答
  • 2020-12-05 15:42

    It doesn't seem to be possible to change the culture. See this KB article.

    0 讨论(0)
  • 2020-12-05 15:53

    For DateTimePicker

    dtp.Format = DateTimePickerFormat.Custom;
    dtp.CustomFormat = "yyyy-MM-dd"; // or the format you prefer
    
    0 讨论(0)
  • 2020-12-05 16:00

    Based on previous solution, I think the better is:

    dateTimePicker.Format = DateTimePickerFormat.Custom;
    dateTimePicker.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;
    
    0 讨论(0)
  • 2020-12-05 16:01

    I think there is detour.

    1. set event handler "ValueChanged"
    2. code

      dateTimePicker.Format = DateTimePickerFormat.Custom;
      string[] formats = dateTimePicker.Value.GetDateTimeFormats(Application.CurrentCulture);
      dateTimePicker.CustomFormat = formats[0];
      
    0 讨论(0)
  • 2020-12-05 16:02
    System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr");
    System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;
    
    0 讨论(0)
  • 2020-12-05 16:05

    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;
    
    0 讨论(0)
提交回复
热议问题