We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Click on weeknumber -> change to Worweek view

Thread ID:

Created:

Updated:

Platform:

Replies:

69003 Oct 9,2007 05:56 AM Sep 12,2018 04:58 AM Windows Forms 7
loading
Tags: ScheduleControl
Samy Abou-Shama
Asked On October 9, 2007 05:56 AM

Hi,

when one clicks the week number in the calendar, the week is displayed in the ScheduleViewType.Week.
Is it possible to change this behaviour, so that the view type is ScheduleViewType.WorkWeek instead?

Thank you for you help.

Samy Abou-Shama

Administrator [Syncfusion]
Replied On October 10, 2007 09:45 AM

There is no event or property you can set to get this behavior.

So for now, you would have to get at the embedded GridControl that is in the NavigationCalendar. This requires deriving the ScheduleControl, NavigationCalendar and GridControl. You need to derive the first 2 classes just to create the proper instance of the latter 2 classes.

Inside the GridControl, you would override OnClick and catch the clicks there. If the click is on the month header, you would switch to the MonthView and if the click is on the week number, you would switch to the workweek view. In both cases, you set e.Cancel = true and not call the base class to prevent the default behavior from occurring. It takes little work to do this. Here is a minimal sample that attempts it.


SampleSchedule.zip

Felix Bagur
Replied On September 4, 2018 05:15 AM

In the current version there is a simpler solution? I have tried the example but it does not work correctly.

Thanks!,
Felix

Mohanraj Gunasekaran [Syncfusion]
Replied On September 5, 2018 08:49 AM

Hi Felix,  
  
Thanks for using Syncfusion product.  
  
To avoid the view changing while clicking on the week number, you could disable the SwitchViewStyle property. Please refer the following code example,  
  
Code example  
//To handle the view changing of scheduleControl.  
this.scheduleControl1.SwitchViewStyle = false;  
  
If you want to change the schedule view using ScheduleControl context menu. You could use the CalenderGrid.MouseDown and ScheduleContextMenuClick event to handle the SwitchViewStyle property. Please refer the following code example and the sample,  
  
Code example  
this.scheduleControl1.Calendar.CalenderGrid.MouseDown += CalenderGrid_MouseDown;  
this.scheduleControl1.ScheduleContextMenuClick += ScheduleControl1_ScheduleContextMenuClick;  
private void ScheduleControl1_ScheduleContextMenuClick(object sender, ScheduleContextMenuClickEventArgs e)  
{  
    if (!this.scheduleControl1.SwitchViewStyle)  
        this.scheduleControl1.SwitchViewStyle = true;  
}  
  
private void CalenderGrid_MouseDown(object sender, MouseEventArgs e)  
{  
    this.scheduleControl1.SwitchViewStyle = false;  
}  
  
  
Mohanraj G 


Felix Bagur
Replied On September 5, 2018 08:57 AM

Thanks for your quick response,

The problem comes when you click on the week number, not on a calendar day. 

Clicking on the week number keeps changing to the whole week even if you have disabled SwitchViewStyle.

I would like to be able to click on a day of the calendar and get the daily view and click on the week number and get the work week.

Thanks a lot,

Fèlix


Arulraj A [Syncfusion]
Replied On September 6, 2018 05:15 AM

 
Sorry for the inconvenience caused. 
 
To avoid the view changing while clicking on the week number, you could handle the CalendarGrid.CellClick event. Please refer the following code example and the sample, No need to disable the SwitchViewStyle property. 
 
Code example 
this.scheduleControl1.Calendar.CalenderGrid.CellClick += CalenderGrid_CellClick; 
 
private void CalenderGrid_CellClick(object sender, Syncfusion.Windows.Forms.Grid.GridCellClickEventArgs e) 
{ 
    if (e.ColIndex == 1 && (this.scheduleControl1.ScheduleType == ScheduleViewType.WorkWeek || scheduleControl1.ScheduleType == ScheduleViewType.Day)) 
    { 
        GridStyleInfo style = this.scheduleControl1.Calendar.CalenderGrid[e.RowIndex, e.ColIndex]; 
        DateTime dateValue; 
        if (DateTime.TryParse(style.CellValue.ToString(), out dateValue)) 
        { 
            while (dateValue.DayOfWeek == DayOfWeek.Saturday || dateValue.DayOfWeek == DayOfWeek.Sunday) 
            { 
                //To get the week days of current week. 
                dateValue = dateValue.AddDays(1); 
            } 
 
            this.scheduleControl1.Calendar.SelectedDates.BeginUpdate(); 
            if (this.scheduleControl1.ScheduleType == ScheduleViewType.Day) 
                this.scheduleControl1.Calendar.SelectedDates[0] = dateValue; 
            else 
            { 
                this.scheduleControl1.Calendar.SelectedDates.Clear(); 
                this.scheduleControl1.Calendar.SelectedDates.Add(dateValue); 
            } 
            this.scheduleControl1.Calendar.SelectedDates.EndUpdate(); 
            this.scheduleControl1.GetScheduleHost().SwitchTo(ScheduleViewType.WorkWeek, true); 
        } 
        e.Cancel = true; 
    } 
} 
 
 
Arulraj A 


Felix Bagur
Replied On September 12, 2018 03:16 AM

Thanks for you update!, it works!
Fèlix

Mohanraj Gunasekaran [Syncfusion]
Replied On September 12, 2018 04:58 AM

 
Thanks for your update. 
 
We are glad to know that your reported problem has resolved. 
 
Please let us know if you have any concerns. 
 
Regards, 
Mohanraj G 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;