none
Can't change The Calendar of DateTimePicker

    Question

  • I want to change the calendar displayed in the DateTimePicker Control to HijriCalendar in Windows Forms Application But I Failed

    for other controls such as displayed date in the DataGridView Control I've Changed the calendar of all application using this code in The Application startup Event and it worked Ok But Not For The DateTimePicker Control


    Dim Ar As CultureInfo = New CultureInfo("ar-SY")

    Thread.CurrentThread.CurrentCulture = Ar

    Ar.DateTimeFormat.Calendar = New HijriCalendar

    Tuesday, September 30, 2008 9:18 AM

All replies

  • To troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Thursday, October 02, 2008 7:03 AM
  • Ok no problem

    this is a link to a simple project displaying the problem using vb2008 express
    http://www.megaupload.com/?d=D7E7VB80

    the file called "WindowsApplication9.zip" (16.32 KB)


    see the output picture at the link
    http://www.megaupload.com/?d=CKKIMIZ6
    the file called "MyProblem.jpg" (33.08 KB)
    • Edited by Samer Selo Thursday, October 02, 2008 3:36 PM add form picture
    Thursday, October 02, 2008 3:29 PM
  • note: the code in the example is

    Dim Ar As CultureInfo = New CultureInfo(Thread.CurrentThread.CurrentCulture.Name)

    Thread.CurrentThread.CurrentCulture = Ar

    Ar.DateTimeFormat.Calendar = New HijriCalendar

    and it's different to the code originally posted by me and it produce the same problem ofcourse you can use the code orgiginally posted by me instaed and you will get the same result

    Thursday, October 02, 2008 3:40 PM
  • Check its Format property. This property sets the DateTimePickerFormat of the control. The default date Format is DateTimePickerFormat.Long. If the Format property is set to DateTimePickerFormat.Custom, you can create your own format style by setting the CustomFormat property and building a custom format string. The custom format string can be a combination of custom field characters and other literal characters. For example, you can display the date as "June 01, 2001 - Friday" by setting the CustomFormat property to "MMMM dd, yyyy - dddd".


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, October 06, 2008 11:10 AM
  • Thank you
    this will change the format but still the displayed date in gregorian calendar not in hijri calendar
    Monday, October 06, 2008 4:00 PM