Completed
Last Updated: 15 Aug 2017 10:20 by ADMIN
ADMIN
Hristo
Created on: 07 Mar 2017 12:21
Category: Editors
Type: Bug Report
2
FIX. RadDateTimePicker - ArgumentOutOfRangeException when using HeaderNavigationMode = Zoom and having the focused data to equal the min date
How to reproduce: 
public partial class Form1 : Form
{
    RadDateTimePicker dateTimePicker;
    public Form1()
    {
        InitializeComponent();

        this.dateTimePicker = new RadDateTimePicker();
        this.dateTimePicker.DateTimePickerElement.Calendar.HeaderNavigationMode = HeaderNavigationMode.Zoom;
        this.Controls.Add(this.dateTimePicker);
    }
}

Workaround:
public partial class Form1 : Form
    {
        RadDateTimePicker dateTimePicker;
        public Form1()
        {
            InitializeComponent();

            this.dateTimePicker = new RadDateTimePicker();
            this.dateTimePicker.DateTimePickerElement.Calendar.PropertyChanged += Calendar_PropertyChanged;

            this.dateTimePicker.DateTimePickerElement.Calendar.HeaderNavigationMode = HeaderNavigationMode.Zoom;
            this.Controls.Add(this.dateTimePicker);
        }

        private void Calendar_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (e.PropertyName == "FocusedDate")
            {
                int year = this.dateTimePicker.DateTimePickerElement.Calendar.FocusedDate.Year;
                if (year <= this.dateTimePicker.MinDate.Year)
                {
                    this.dateTimePicker.DateTimePickerElement.Calendar.HeaderNavigationMode = HeaderNavigationMode.None;
                }
                else
                {
                    this.dateTimePicker.DateTimePickerElement.Calendar.HeaderNavigationMode = HeaderNavigationMode.Zoom;
                }
            }
        }
    }

0 comments