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
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.
KB link: https://www.syncfusion.com/kb/6736/how-to-hook-an-event-for-winforms-schedulecontrol-context-menu
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");
} |