Is there an event we can attach to when the schedule view type is changed?

We are creating our own buttons (checkboxes) to change the view type to Day, Week or Month and we are able to switch the view type programatically using the PerformSwitchToScheduleViewTypeClick method. Additionally, we would also like to be able to update our checkboxes if the view type is changed by clicking on the NavigationPanel date items or the main grid date cells. We could not seem to find an event we can use to accomplish this. Is there an event we can attach to when the schedule view type is changed?

Thanks in advance.

3 Replies 1 reply marked as answer

BT Balamurugan Thirumalaikumar Syncfusion Team July 20, 2020 01:15 PM UTC

Hi Peregrino,

Thank you for using the Syncfusion Products.

In order to notify the application when the view type is changed, the DateValueChanging event can be used. In that event, the ScheduleViewType can be updated to ComboBox selected item. Please make use of the below code and sample. 

Example of code

//Event subscription

this.comboBox1.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged);

//Event subscription

this.scheduleControl1.GetScheduleHost().Calendar.DateValueChanging += Calendar_DateValueChanging;

 

//Event suscription

//For dayvalue changed

private void Calendar_DateValueChanging(object sender, EventArgs e)

{

    if (scheduleControl1.ScheduleType == ScheduleViewType.Month)

        comboBox1.SelectedItem = ScheduleViewType.Month;

}

 

//Event suscription

//For Combox changed

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)

{

    if (comboBox1.SelectedItem.ToString() == ScheduleViewType.Day.ToString())

        this.scheduleControl1.PerformSwitchToScheduleViewTypeClick(ScheduleViewType.Day);

    if (comboBox1.SelectedItem.ToString() == ScheduleViewType.Month.ToString())

        this.scheduleControl1.PerformSwitchToScheduleViewTypeClick(ScheduleViewType.Month);

    if (comboBox1.SelectedItem.ToString() == ScheduleViewType.WorkWeek.ToString())

        this.scheduleControl1.PerformSwitchToScheduleViewTypeClick(ScheduleViewType.WorkWeek);

    if (comboBox1.SelectedItem.ToString() == ScheduleViewType.Week.ToString())

        this.scheduleControl1.PerformSwitchToScheduleViewTypeClick(ScheduleViewType.Week);

}


SampleLink:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/ScheduleSample_(2)334894035.zip


Please get back to us, if you need any further assistance.


Thanks & Regards,

Balamurugan Thirumalaikumar 




PE Peregrino July 20, 2020 01:41 PM UTC

Hi Balamurugan,

Thanks for the sample project. We were already able to change the view type using PerformSwitchToScheduleViewTypeClick. What we are more interested in is how we should handle the internal control events that trigger the changing of the view type so we can update the combobox (similar to the sample) such as the following:

1. View type is changed to Day by clicking on a date cell in the navigation calendar
2. View type is changed by clicking on the context menu option (right-click > select calendar view type)

scheduleControl1.GetScheduleHost().Calendar.DateValueChanging seems incomplete and does not handle the scenarios above.

Thank you in advance.

Regards,
Peregrino


BT Balamurugan Thirumalaikumar Syncfusion Team July 21, 2020 03:57 PM UTC

Hi Peregrino, 
Thank you for the update, 
View type is changed to Day by clicking on a date cell in the navigation calendar 
The DateValue for the CalendarGrid will be set internally when the month is changed using the navigation button or ContextMenuItems click is occurred. In order to notify the application when the ScheduleViewType is changed by clicking on the calendar, we suggest you to use the SelectionsChanged event of SelectedDates collection. 
 
Example code  
//Event subscription 
this.scheduleControl1.Calendar.SelectedDates.SelectionsChanged += Calendar_SelectionsChanged; 
  
private void Calendar_SelectionsChanged(object sender, EventArgs e) 
 { 
   this.scheduleControl1.Calendar.DateValue = this.scheduleControl1.Calendar.DateValue.A 
View type is changed by clicking on the context menu option (right-click > select calendar view type) 
The Click event for each items in the ContextMenu can be used to notify the context menu item click in ScheduleControl. We already provided a knowledge base to achieve this use and please make use of the below KB for further details. 
 

ExampleCode: 
//Event subscription 
foreach (MenuItem item in this.scheduleControl1.GetScheduleHost().ContextMenu.MenuItems) 
{ 
    item.Click += item_Click; 
} 
 
//Event subscription 
private void item_Click(object sender, EventArgs e) 
  MenuItem item = sender as MenuItem;    MessageBox.Show( item.Text +" Item clicked"); 
}  

Thanks & Regards, 
Balamurugan Thirumalaikumar

Marked as answer
Loader.
Up arrow icon