Search code examples
datetimepicker

How to change the calendar type in dateTimePicker?


i try to change the calendar type in dateTimePicker from gregorian to hijri but i cant cuz the system calender type it's gregorian .

i try this code

 CultureInfo ci = new CultureInfo("ar-SA");
 DateTimeFormatInfo info = ci.DateTimeFormat;
 dateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
 dateTimePicker1.CustomFormat = info.ShortDatePattern + " " + info.ShortTimePattern;

but not working !?

how i can change it in my App?


Solution

  • From MSDN:

    The DateTimePicker control only supports Gregorian calendars.

    But you can create a custom calendar, check out these articles (C#):

    Windows Hijri Calendar

    ASP.NET DatePicker User Control (Hijri / Gregorian)

    How to create a Hijri Calendar control in .Net Framework 2.0