Completed
Last Updated: 06 Jun 2014 08:11 by ADMIN
ADMIN
Stefan
Created on: 11 Sep 2013 10:17
Category: Editors
Type: Bug Report
1
FIX. RadDateTimePicker - having the MinDate and NullDate set to the same value, would cause the control to return incorrect Value
To reproduce:
            radDateTimePicker1.MinDate = new DateTime(2013, 9, 1);
            radDateTimePicker1.MaxDate = new DateTime(2013, 9, 15);
            radDateTimePicker1.NullDate = new DateTime(2013, 9, 1);
            radDateTimePicker1.NullText = "text";

Start the app and set the year to "1111", then click some button to cause the date time picker to lose focus. At this point, print the control Text and Value. While the text is correct, the value shows with year "1111" and is not validated by the MinDate 2013/9/1

Workaround - work with null and NullableValue instead of NullDate and a specific date, or use the following class

   class MyRadDateTimePicker : RadDateTimePicker
        {
            public override DateTime Value
            {
                get
                {
                    DateTime? date = this.DateTimePickerElement.Value;
                    if (date.HasValue)
                    {
                        if (date < this.MinDate)
                        {
                            return this.MinDate;
                        }

                        if (date > this.MaxDate)
                        {
                            return this.MaxDate;
                        }

                        return date.Value;
                    }

                    return this.MinDate;
                }
                set
                {
                    base.Value = value;
                }
            }
0 comments