How to limit selectable dates

7 posts, 2 answers
  1. Daniel
    Daniel avatar
    91 posts
    Member since:
    Jan 2008

    Posted 26 May 2008 Link to this post

    Is it possible to limit selectable dates in DateTimePicker dropdown list? Also, how to deselect what user selected? When I change control's Value, it's displayed as selected with the date user picked too.
  2. Answer
    Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 29 May 2008 Link to this post

    Hello Daniel,

    To limit the range of selection, you should use the MinDate and MaxDate properties of RadDateTimePicker.
    RadDateTimePicker uses internally a RadCalendar. You can access it as shown below:

       RadCalendar calendar = (this.radDateTimePicker1.DateTimePickerElement.GetCurrentBehavior() as RadDateTimePickerCalendar).Calendar;

    RadCalendar keeps a collection of the currently selected dates. You can access this collection using the SelectedDates property of RadCalendar. As a common collection, you can remove its items which are the selected dates.

    I hope this helps. Do not hesitate to contact me if you need additional information.

    Sincerely yours,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Daniel
    Daniel avatar
    91 posts
    Member since:
    Jan 2008

    Posted 29 May 2008 Link to this post

    Thank you Boyko for pointers. I'll check it out.

    I'd like to just specific weekdays selectable - i.e. just Mondays. Is that possible?

    Regards,
    Daniel
  5. Answer
    Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 30 May 2008 Link to this post

    Hello Daniel,

    You could subscribe to the SelectionChanging and SelectionChanged events of RadCalendar and add custom logic in the event handlers to remove certain dates from the SelectedDates collection or disable the corresponding cells in the RadCalendar.

    You could also hide the days from the other months in RadCalendar  To hide the other months days from the RadCalendar view, use the ShowOtherMonthsDays property of RadCalendar which is true by default.

    I hope this helps. Contact me if you need additional information.

    Best wishes,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Daniel
    Daniel avatar
    91 posts
    Member since:
    Jan 2008

    Posted 30 May 2008 Link to this post

    Yes, that's it. Disabling the corresponding cells in the RadCalendar. I'll try it. Thanks so far
  7. Soeren Kohls
    Soeren Kohls avatar
    1 posts
    Member since:
    Nov 2009

    Posted 18 Jan 2010 Link to this post

    Hello,

    I try to limit the selectable Dates in the Calendar Control to 5, but the control does not render correct afterwards, it does not deselect the removed dates. When you switch do the next month and back to the selection, the controls displays the correct selection.

    Sometimes it helps to switch the focus date to another date and then back to the current, but this doesn't work in every situation and it displays the date in different colors.


            private void rc_MouseUp(object sender, MouseEventArgs e)

            {

                if (rc.SelectedDates.Count > 5)

                {

                    rc.SelectedDates.Remove(rc.SelectedDates[5]);

                    DateTime temdate = rc.FocusedDate;

                    rc.FocusedDate = temdate.AddDays(1);

                    rc.FocusedDate = temdate;               

                }

            }


    Same behavior in other events like SelectionChanged, ...

     

     

     

  8. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 21 Jan 2010 Link to this post

    Hello Soeren Kohls,

    I  have just tested this issue with the latest version of RadCalendar Q3 Sp1 2009 and it seems to work properly. However, you can also try calling the InvalidateCalendar method to explicitly invalidate the calendar if it is necessary. Please contact us again if you have additional questions.

    All the best,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top
UI for WinForms is Visual Studio 2017 Ready