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. Image for the cookie policy date
close icon

Make the schedule readonly

Hi,

I need to show some books made on my app into the scheduleControl.

So I linked a button to a new Form. As I don't want the uer to be able to change the events from the schedule, I canceled the  event showing the appointment form. But when I close the form I still have the messageBox asking if I want to discard changes. How can I disable this messageBox ?

I'd like also to display week-end in the WorkWeek view, is this possible ? 

Attachment: Capture_d’écran_(1)_1ca24d17.zip

1 Reply

MG Mohanraj Gunasekaran Syncfusion Team September 13, 2017 01:28 PM UTC

Hi Nicolas, 

Thanks for using Syncfusion product. 

Query 
Solution 
I linked a button to a new Form. As I don't want the uer to be able to change the events from the schedule, I canceled the event showing the appointment form. But when I close the form I still have the messageBox asking if I want to discard changes. How can I disable this messageBox ? 
In order to avoid the MessageBox showing when closing the form. SaveOnCloseBehaviorAction property can be used. Please refer to the below code example, 
 
Code example 
this.scheduleControl1.DataSource.SaveOnCloseBehaviorAction = SaveOnCloseBehavior.SaveWithoutPrompt; 
I'd like also to display week-end in the WorkWeek view, is this possible ?  
In order to display the week end in WorkWeek view, you can use the CustomWeek schedule view and SelectedDates property can be used to add the dates in ScheduleControl. Please refer to the below code example and the sample, 

Code example 
this.scheduleControl1.GetScheduleHost().Calendar.SelectedDates.Clear(); 
this.GetWeekDays(); 
 
private void GetWeekDays() 
{ 
    int count = 7;//No of days in week. 
    this.scheduleControl1.GetScheduleHost().Calendar.SelectedDates.BeginUpdate(); 
    DateTime theDate = this.scheduleControl1.GetScheduleHost().Calendar.DateValue; 
    while (theDate.DayOfWeek != this.scheduleControl1.Appearance.NavigationCalendarStartDayOfWeek) 
    { 
        theDate = theDate.AddDays(-1); 
    } 
 
    this.scheduleControl1.GetScheduleHost().Calendar.SelectedDates.Clear(); 
    while (count > 0) 
    { 
        this.scheduleControl1.GetScheduleHost().Calendar.SelectedDates.Add(theDate); 
        theDate = theDate.AddDays(1); 
        count--; 
    } 
    this.scheduleControl1.GetScheduleHost().Calendar.SelectedDates.EndUpdate(); 
} 
 
Note 
If you want to navigate the weeks using caption panel arrow. Please use the below code, 
 
Code example 
foreach (Control con in this.scheduleControl1.CaptionPanel.Controls) 
{ 
    if (con is ThemedScrollButton) 
    { 
        ThemedScrollButton button = con as ThemedScrollButton; 
        button.Click += button_Click; 
    } 
} 
 
void button_Click(object sender, EventArgs e) 
{ 
    ThemedScrollButton button = sender as ThemedScrollButton; 
            
    if (button.Text == "<")//Move to previous week 
    { 
        this.MoveInDirection(false); 
    } 
    else if (button.Text == ">") //Move to week forward 
    { 
        this.MoveInDirection(true); 
    } 
} 
 

Sample link: ScheduleControl 

Regards, 
Mohanraj G 
 


Loader.
Live Chat Icon For mobile
Up arrow icon