8 Answers, 1 is accepted
Thank you for writing.
RadCalendar features SelectionChanging event, which will get triggered when the selection has been changed. In your scenario, in the event you can access the e.NewDates property to get the newly selected date.
More information on the events provided by RadCalendar, can be found here.
I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.
Regards,
Stefan
Telerik

Hi Stefan,
I want to describe about my scenario. When I click on a day, I want whole week is selected instead of one day, so I can not use SelectionChanging event, because when user click, the SelectionChanging is raised, then I get the selected date by e.NewDates, I calculate and add dates in week from that date, then add to SelectedDates property, this will raise SelectionChaging again.
Therefore, I don't use SelectionChanging event, I use Click event and get the last clicked date from FocusedDate Property. I have just found this property, and it work find.
Thank for your answer.
Pham Thanh
I am glad you found a way to handle your scenario, indeed the Click event is the other option.
I would like to just add, that row/column selection is available as functionality with the column/row headers. Here you can find more information on this matter: http://docs.telerik.com/devtools/winforms/calendar/customizing-behavior/column-and-row-headers and also here is a small snippet:
radCalendar1.AllowMultipleSelect =
true
;
radCalendar1.ShowRowHeaders =
true
;
radCalendar1.AllowRowHeaderSelectors =
true
;
I hope that you find this information useful.
Regards,
Stefan
Telerik

Is it possible to select more than one week per month when using the row header as the selector? it appears that currently when I click a row header to select a week, it automatically deselects any other selections I have for the month. Is this intended behavior? Also - is it possible to determine if the cell I have clicked on is a header cell versus a regular calendar cell?
Thanks.
Thank you for writing.
The multiple selection should be kept no matter if you click a date cell or the header cell. 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 MouseDown event to store the currently selected cells and then on MouseUp restore the missing selection:
public
class
MyCalendar : RadCalendar
{
List<DateTime> selectedDays =
new
List<DateTime>();
protected
override
void
OnMouseDown(MouseEventArgs e)
{
CalendarCellElement cell =
this
.ElementTree.GetElementAtPoint(e.Location)
as
CalendarCellElement;
if
(cell !=
null
)
{
bool
isHeader = (
bool
)cell.GetValue(CalendarCellElement.IsHeaderCellProperty);
if
(isHeader)
{
selectedDays.Clear();
foreach
(DateTime date
in
this
.SelectedDates)
{
selectedDays.Add(date);
}
}
}
base
.OnMouseDown(e);
}
protected
override
void
OnMouseUp(MouseEventArgs e)
{
base
.OnMouseUp(e);
foreach
(DateTime date
in
selectedDays)
{
if
(!
this
.SelectedDates.Contains(date))
{
this
.SelectedDates.Add(date);
}
}
}
public
override
string
ThemeClassName
{
get
{
return
typeof
(RadCalendar).FullName;
}
}
}
I hope this information helps. Should you have further questions I would be glad to help.
Regards,
Dess
Progress Telerik

Thanks Dess, this worked great for adding multiple selections, but it no longer allows me to deselect a week. For example, I select 7 weeks all using the week headers, but then I decide I want to deselect one of the weeks, I can no longer do that. Any suggestions on how to achieve being able to select and deselect multiple weeks using the week headers?
Thanks.
PS - I sure wish you guys offered a "WeekHeaderClicked" event to give us programmers more control over what to do when a week header is clicked. It would even be helpful if the date value of the week header cell wasn't the 1st day of the month. Just a suggestion.
Thank you for writing back.
Here is the modified code snippet demonstrating how to unselect the selected row in RadCalendar:
protected
override
void
OnMouseDown(MouseEventArgs e)
{
CalendarCellElement cell =
this
.ElementTree.GetElementAtPoint(e.Location)
as
CalendarCellElement;
if
(cell !=
null
)
{
bool
isHeader = (
bool
)cell.GetValue(CalendarCellElement.IsHeaderCellProperty);
if
(isHeader)
{
MonthViewElement monthView =
this
.CalendarElement.CalendarVisualElement
as
MonthViewElement;
foreach
(CalendarCellElement c
in
monthView.TableElement.Children)
{
if
(cell.Row == c.Row && c.Selected)
{
this
.SelectedDates.Remove(c.Date);
}
}
selectedDays.Clear();
foreach
(DateTime date
in
this
.SelectedDates)
{
selectedDays.Add(date);
}
}
}
base
.OnMouseDown(e);
}
Note that this is just a sample approach and it may not cover all possible cases. Note that the fix is scheduled for the upcoming service pack in the middle of June.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Progress Telerik

Dess,
Thanks so much! This should be fine until the service pack comes out.