Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
375
UltraDateTimeEditor and MaxDate
posted

Can anyone explain why although the MaxDate property is a DateTime you cannot set it to DateTime.MaxValue.

 i.e. myDateEditor.MaxDate = DateTime.MaxValue;   causes an exception.

I had a look with reflector, on the set of the property a comparation is made to a private static variable called "defaultMaxDate", if the value is greater than defaultMaxDate the out of range exception is thrown. It appears the value of defaultMaxDate is 31/12/998 (DateTime.MaxValue is 31/12/999).

Im just a bit confused as to what purpose this serves ?

Thanks

Parents
No Data
Reply
  • 469350
    Offline posted

     Hi Mark,

    I took a look and found some notes from the developers about why we do this: 

            //    Note that we do this because for some reason the static
            //    DateTime.MinValue property doesn't show up in the VB property grid (???), and
            //    MaxValue shows up, but with the time portion (11:59)
            //
            //    Furthermore, the static DateTime.MaxValue is 12/31/9999, and the default MaxDate
            //    for the MonthCalendar control (which is used both by the DateTimeEditor and the VB
            //    property grid) is 12/31/9998

Children