Domanda

Come impostare l'internazionalizzazione su un controllo DateTimepicker o Calendar WinForm in .Net quando la cultura del desiderio è diversa da quella installata nel PC?

È stato utile?

Soluzione

Non sembra possibile cambiare la cultura. Vedi questo articolo KB .

Altri suggerimenti

Sulla base della soluzione precedente, penso che il migliore sia:

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;

Per DateTimePicker

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

Penso che ci sia una deviazione.

  1. imposta il gestore eventi " ValueChanged "
  2. codice

    dateTimePicker.Format = DateTimePickerFormat.Custom;
    string[] formats = dateTimePicker.Value.GetDateTimeFormats(Application.CurrentCulture);
    dateTimePicker.CustomFormat = formats[0];
    
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top