This is a migrated thread and some comments may be shown as answers.

How to limit selectable dates

6 Answers 328 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 26 May 2008, 04:51 PM
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.

6 Answers, 1 is accepted

Sort by
0
Accepted
Boyko Markov
Telerik team
answered on 29 May 2008, 03:32 PM
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
0
Daniel
Top achievements
Rank 1
answered on 29 May 2008, 03:39 PM
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
0
Accepted
Boyko Markov
Telerik team
answered on 30 May 2008, 01:38 PM
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
0
Daniel
Top achievements
Rank 1
answered on 30 May 2008, 01:51 PM
Yes, that's it. Disabling the corresponding cells in the RadCalendar. I'll try it. Thanks so far
0
Soeren Kohls
Top achievements
Rank 1
answered on 18 Jan 2010, 02:11 PM

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, ...

 

 

 

0
Boyko Markov
Telerik team
answered on 21 Jan 2010, 12:29 PM
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.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Daniel
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
Daniel
Top achievements
Rank 1
Soeren Kohls
Top achievements
Rank 1
Share this question
or