Skip to main content

How to: Prevent Appointments and Resources from Reloading

  • 2 minutes to read

In the following example the SchedulerDataStorage.AppointmentCollectionAutoReloading and SchedulerDataStorage.ResourceCollectionAutoReloading events are handled to prevent appointments and appointment resources from being reloaded from a data source in the following cases:

  • When a data source item (row) is being moved to a new position.
  • When a column (field) is added, modified or deleted in the data source.
 using System.ComponentModel;
 using DevExpress.XtraScheduler;
 // ...

 // Subscribe to the event which controls data reloading 
 // for the data source which contains appointments.
 schedulerControl.DataStorage.AppointmentCollectionAutoReloading += 
    new CancelListChangedEventHandler(OnCollectionAutoReloading);

 // Subscribe to the event which controls data reloading 
 // for the data source which contains appointment resources.
 schedulerControl.DataStorage.ResourceCollectionAutoReloading += 
    new CancelListChangedEventHandler(OnCollectionAutoReloading);


 private void OnCollectionAutoReloading(object sender, 
    CancelListChangedEventArgs e) {
    // Prevent data reloading when the data source is modified in specific cases.
    if(e.ListChangedType == ListChangedType.ItemMoved || e.ListChangedType == 
        ListChangedType.PropertyDescriptorAdded || 
        e.ListChangedType == ListChangedType.PropertyDescriptorChanged || 
        e.ListChangedType == ListChangedType.PropertyDescriptorDeleted)
       e.Cancel = true;
 }