Calendar - ENTIRE WEEK selection

2 posts, 0 answers
  1. James
    James avatar
    15 posts
    Member since:
    Feb 2016

    Posted 03 Aug Link to this post

    I am using the 2016 Q2 release of the RadCalendar control...


    I have reviewed the years old threads regarding the week selection in a Calendar control and I am still unable to achieve what I am after.  Hopefully someone can help...


    When the form is loaded, I want the Calendar to display the month for the system date, and select all days in the associated week for the system date, using a Sunday - Saturday week format. So if today is Aug 3, 2016, I would want the Calendar to display 7 columns, 6 rows, showing dates Jul 31, 2016 to Sep 10, 2016, with the dates for the current week, Jul 31, 2016 to Aug 6, 2016 selected.


    Additionally, if the User selects any other date in the Calendar, I want to clear to previous week selection, and select all days in the associated week for the select date, using a Sunday - Saturday week format. So if User selects Aug 24, 2016, I would want the previous week to not be selected, and select all days for which the selected date falls between, Aug 21, 2016 - Aug 27, 2016.


    In the end, there would only ever be 7 days selected in the Calendar which would equal 1 week in time.


    Any guidance would be most appreciated.



  2. Dess
    Dess avatar
    1560 posts

    Posted 04 Aug Link to this post

    Hello James,

    Thank you for writing. 

    In order to achieve week selection, you can clear all dates that don't belong to the week from the SelectedDates collection and select each date of the week. Here is demonstrates a sample code snippet which result is illustrated on the attached gif file:
    public partial class Form1 : Form
        public Form1()
            this.radCalendar1.AllowMultipleSelect = true;
            this.radCalendar1.SelectionChanged += radCalendar1_SelectionChanged;
        private void radCalendar1_SelectionChanged(object sender, EventArgs e)
            this.radCalendar1.SelectionChanged -= radCalendar1_SelectionChanged;
            if (this.radCalendar1.SelectedDates.Count != 1)
                while (this.radCalendar1.SelectedDates.Count > 1)
            DateTime startDate = this.radCalendar1.SelectedDates.First().StartOfWeek(DayOfWeek.Monday).AddDays(-1);
            DateTime endDate = startDate.AddDays(6);
            while (startDate <= endDate)
                startDate = startDate.AddDays(1);
            this.radCalendar1.SelectionChanged += radCalendar1_SelectionChanged;
    public static class DateTimeExtensions
        public static DateTime StartOfWeek(this DateTime dt, DayOfWeek startOfWeek)
            int diff = dt.DayOfWeek - startOfWeek;
            if (diff < 0)
                diff += 7;
            return dt.AddDays(-1 * diff).Date;

    Note that this is just a sample code snippet and it may not cover all possible cases. Feel free to modify it in a way which suits your requirement best.

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

    Telerik by Progress
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. DevCraft banner
Back to Top