Krypton-Suite-Legacy-Archive / Krypton-NET-5.470

A update to Component factory's krypton toolkit to support the .NET 4.7 framework.
BSD 3-Clause "New" or "Revised" License
78 stars 20 forks source link

DateTimePicker max date #197

Closed rahulmaxi closed 5 years ago

rahulmaxi commented 5 years ago

Hi,

Is there anyway DateTimePicker max date can be set to 9999-12-31? At the moment it can be set max to 9998-12-31.

Thanks, Rahul

PWagner1 commented 5 years ago

Hi @rahulmaxi

I'll look into this, might be a case of implementing it via code.

PWagner1 commented 5 years ago

Update: It seems to rely on the system's max date, transferring to standard toolkit for fix.

PWagner1 commented 5 years ago

Hi @Smurf-IV

Is this bug due to the fact that DateTime.MaxValue is a 32 bit integer?

Smurf-IV commented 5 years ago

KryptonDateTimePicker has a value that is _maxDateTime = DateTime.MaxValue; which can be changed via

    [Category("Behavior")]
    [Description("Maximum allowable date.")]
    public DateTime MaxDate

DateTime.MaxValue; according to MSDN is:

The value of this constant is equivalent to 23:59:59.9999999 UTC, December 31, 9999 in the Gregorian calendar, exactly one 100-nanosecond tick before 00:00:00 UTC, January 1, 10000.

BUT the DateTimePicker.MaximumDateTime is also in use here!

/// <include file='doc\DateTimePicker.uex' path='docs/doc[@for="DateTimePicker.MaximumDateTime"]/*' />
    /// <devdoc>
    ///    <para>Specifies the maximum date value. This property is read-only.</para>
    /// </devdoc>
    public static DateTime MaximumDateTime {
    get {
             DateTime maxSupportedDateTime = CultureInfo.CurrentCulture.Calendar.MaxSupportedDateTime;
             if (maxSupportedDateTime.Year > MaxDateTime.Year)
             {
                 return MaxDateTime;
             }
             return maxSupportedDateTime;
         }
    }

Which is explained here as to why the value is 9998 (Not really), and also there is a way to "Hack around it" if you must: https://stackoverflow.com/questions/1620858/how-to-set-a-datetimepicker-value-to-datetime-maxvalue