windowsforms-2303-controls-and-libraries-scheduler-examples-data-binding-how-to-prevent-appointments-and-resources-from-reloading.md
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;
}
Imports System.ComponentModel
Imports DevExpress.XtraScheduler
' ...
' Subscribe to the event which controls data reloading
' for the data source which contains appointments.
AddHandler SchedulerDataStorage1.AppointmentCollectionAutoReloading, _
New CancelListChangedEventHandler(AddressOf OnCollectionAutoReloading)
' Subscribe to the event which controls data reloading
' for the data source which contains appointment resources.
AddHandler SchedulerDataStorage1.ResourceCollectionAutoReloading, _
New CancelListChangedEventHandler(AddressOf OnCollectionAutoReloading)
Sub OnCollectionAutoReloading(ByVal sender As Object, _
ByVal e As CancelListChangedEventArgs)
' Prevent data reloading when the data source is modified in specific cases.
If e.ListChangedType = ListChangedType.ItemMoved Or _
e.ListChangedType = ListChangedType.PropertyDescriptorAdded Or _
e.ListChangedType = ListChangedType.PropertyDescriptorChanged Or _
e.ListChangedType = ListChangedType.PropertyDescriptorDeleted Then
e.Cancel = True
End If
End Sub