Completed
Last Updated: 05 Jun 2014 07:08 by Svetlin
Svetlin
Created on: 08 Feb 2013 03:58
Category: Editors
Type: Bug Report
1
FIX. RadDateTimeEditor does not obey MaxDate and MinDate property when the value is changed by keyboard input.
The RadDateTimeEditor does not obey MaxDate and MinDate property when the value is changed by keyboard input.

Work around:

public class MyRadDateTimeEditor : RadDateTimeEditor
    {
        public MyRadDateTimeEditor()
        {
            RadDateTimeEditorElement element = this.EditorElement as RadDateTimeEditorElement;
            element.CurrentBehavior.TextBoxElement.ValueChanged += this.OnValueChanged;
        }

        private void OnValueChanged(object sender, System.EventArgs e)
        {
            RadMaskedEditBoxElement maskBox = sender as RadMaskedEditBoxElement;
            RadDateTimeEditorElement element = this.EditorElement as RadDateTimeEditorElement;

            DateTime result;

            if (maskBox.Value != null && DateTime.TryParse(maskBox.Value.ToString(), out result) && DateTime.Compare(result, element.MaxDate) > 0)
            {
                this.Value = element.MaxDate;
                maskBox.Value = element.MaxDate;
                return;
            }
        }
    }
0 comments