Oscar Cabrero
Oscar Cabrero

Reputation: 4169

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

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

Upvotes: 15

Views: 51198

Answers (6)

user12146889
user12146889

Reputation: 1

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;

Upvotes: -1

KaDim
KaDim

Reputation: 51

Based on previous solution, I think the better is:

dateTimePicker.Format = DateTimePickerFormat.Custom;
dateTimePicker.CustomFormat = Application.CurrentCulture.DateTimeFormat.ShortDatePattern;

Upvotes: 5

heejong
heejong

Reputation: 764

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];
    

Upvotes: -1

Bigballs
Bigballs

Reputation: 3819

System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture("fr");
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Threading.Thread.CurrentThread.CurrentCulture;

Upvotes: 0

Jonas Lincoln
Jonas Lincoln

Reputation: 9787

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

Upvotes: 10

Hapkido
Hapkido

Reputation: 1441

For DateTimePicker

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

Upvotes: 0

Related Questions