Back to Devexpress

SchedulerStorageBase.AppointmentCollectionAutoReloading Event

corelibraries-devexpress-dot-xtrascheduler-dot-schedulerstoragebase-149aa183.md

latest7.9 KB
Original Source

SchedulerStorageBase.AppointmentCollectionAutoReloading Event

Occurs when the data source which contains appointment records is modified and appointments are set to be automatically reloaded.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.Core.Desktop.dll

NuGet Package : DevExpress.Scheduler.CoreDesktop

Declaration

csharp
public event CancelListChangedEventHandler AppointmentCollectionAutoReloading
vb
Public Event AppointmentCollectionAutoReloading As CancelListChangedEventHandler

Event Data

The AppointmentCollectionAutoReloading event's data class is CancelListChangedEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets whether the operation performed on the processed event should be canceled.
ListChangedTypeGets the type of change. Inherited from ListChangedEventArgs.
NewIndexGets the index of the item affected by the change. Inherited from ListChangedEventArgs.
OldIndexGets the old index of an item that has been moved. Inherited from ListChangedEventArgs.
PropertyDescriptorGets the PropertyDescriptor that was added, changed, or deleted. Inherited from ListChangedEventArgs.

Remarks

In bound mode, the SchedulerStorageBase object is bound to a data source which contains appointment records. This data source is specified by the DataMember and DataSource properties of the SchedulerStorage.Appointments object.

When the PersistentObjectStorage<T>.AutoReload property of the SchedulerStorage.Appointments object is set to true the data is automatically reloaded. In this case, the SchedulerStorageBase object reloads data from the data source each time an item in the data source is modified, added, moved or removed, a column is added, modified or deleted or multiple changes are made to the data source. The AppointmentCollectionAutoReloading event allows you to prevent data from being reloaded in specific cases. Use the event’s ListChangedType parameter to get the cause of the data source changes. To prevent data from being reloaded in a specific case set the CancelListChangedEventArgs.Cancel parameter to true. Otherwise, the SchedulerStorageBase object will reload data from the data source immediately after the event handler is completed.

The AppointmentCollectionAutoReloading event doesn’t fire in unbound mode and in bound mode if the PersistentObjectStorage<T>.AutoReload property is set to false.

Example

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.

  • C#

  • VB.NET

csharp
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;
 }
vb
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

Implements

AppointmentCollectionAutoReloading

See Also

ResourceCollectionAutoReloading

SchedulerStorageBase Class

SchedulerStorageBase Members

DevExpress.XtraScheduler Namespace