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

Calendar - Cancel Navigation on doubleclick of day from other month

1 Answer 116 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
scottw
Top achievements
Rank 1
scottw asked on 09 Jun 2014, 05:02 PM
When using Month view, if the user double clicks on a day from another month (previous or next), the calendar navigates to that month before raising MouseDoubleClick on the calendar of DoubleClick on the CalendarCellElement. Is there any way to cancel this navigation and / or another event that fires before the navigation on a double click? I am trying to take action when the user double clicks on a date, but I am losing the date that was clicked because of the navigation. 

For example, If I am displaying the month of June 2014 in the calendar with month view (7 columns x 6 rows horizontal, Monday as the first day of the week) and the user double clicks on the 3rd cell in the first row (representing Wed. May 28), when the CalendarCellElement's DoubleClick event is raised, the Date of the CalendarCellElement is April 2, 2014 (the new date for that cell in the calendar after navigating to the previous month).  I want to either 1) (preferred) capture this event before the navigation so that I may take action on 5/31 OR 2) Prevent the DoubleClick from firing

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 12 Jun 2014, 11:24 AM
Hello Scott,

Thank you for writing.

It is possible to cancel the view changing when a day from the previous/next month is selected. You can use the SelectionChanging event to set a Boolean flag to true and cancel the ViewChanging event:
bool cancelViewChanging = false;
 
public Form1()
{
    InitializeComponent();
    this.radCalendar1.ViewChanging += radCalendar1_ViewChanging;
}
 
private void radCalendar1_ViewChanging(object sender, Telerik.WinControls.UI.ViewChangingEventArgs e)
{
    e.Cancel = cancelViewChanging;
}
 
private void radCalendar1_SelectionChanged(object sender, EventArgs e)
{
    cancelViewChanging = false;
}
 
private void radCalendar1_SelectionChanging(object sender, Telerik.WinControls.UI.SelectionEventArgs e)
{
    cancelViewChanging = true;
}

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

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
scottw
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or