DateTimePicker MinDate = MaxDate

3 posts, 1 answers
  1. Ingo
    Ingo avatar
    21 posts
    Member since:
    Apr 2016

    Posted 05 Dec 2016 Link to this post

    Hello,

    i use a DateTimePicker for my application to select a day. The selection is inside a very narrow time Intervall (1 - 3 Days). So i set the MinDate and MaxDate of the DateTimePicker accourdingly. When the Intervall is lager than 1 day the DateTimePicker works correctly. When the MinDate and the MaxDate is equal (only one day available, date cannot be changed) the display of the DateTimePicker is not correct:

    Only the days before the actual date are grayed out.

    It is possible to switch to different month / years (after teh actual date) with the build in functions.

    Nevertheless is it not possible to select another day (which is good), but the user might get confused that his selection does not change the date.

    Please confirm this behaviour and please provide a workaround for this behaviour.

    Thank You.

    Kind Regads

    Ingo Müller

  2. Answer
    Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4080 posts

    Posted 06 Dec 2016 Link to this post

    Hello Ingo,

    Thank you for writing.  

    I have logged it in our feedback portal and I have added a vote for it on your behalf. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

    I have also updated your Telerik points.

    Currently, the possible solution that I can suggest is to use the RadDateTimePickerCalendar.Calendar.ElementRender event and disable the cells that are not in the applied interval: 

    public RadForm1()
    {
        InitializeComponent();
     
        this.radDateTimePicker1.MinDate = DateTime.Now;
        this.radDateTimePicker1.MaxDate = DateTime.Now;
     
        RadDateTimePickerCalendar calendarBehavior = this.radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar;
        calendarBehavior.Calendar.ElementRender += Calendar_ElementRender;
    }
     
    private void Calendar_ElementRender(object sender, RenderElementEventArgs e)
    {
        if (e.Day.Date > this.radDateTimePicker1.MaxDate.Date || e.Day.Date < this.radDateTimePicker1.MinDate.Date)
        {
            e.Element.Enabled = false;
        }
        else
        {
            e.Element.Enabled = true;
        }
    }

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik by Progress
    Telerik UI for WinForms is ready for Visual Studio 2017 RC! Learn more.
  3. Ingo
    Ingo avatar
    21 posts
    Member since:
    Apr 2016

    Posted 06 Dec 2016 Link to this post

    Hello Dess,

    thank You very much for Your Response and the Workaround!

    It works perfectly!

    Best Regards,

    Ingo Müller

Back to Top