Files to look at:
How to determine whether or not a specific appointment property value is changed
Starting with v18.1
Cast PersistentObjectCancelEventArgs objects to the AdvPersistentObjectCancelEventArgs type to access additional information about the appointment being modified.
- PropertyName - returns the name of the modified appointment property.
- OldValue - the previous value of the modified appointment property.
- NewValue - the new value of the modified appointment property.
Use PropertyName to determine the name of the modified property:
private void SchedulerStorage1_AppointmentChanging(object sender, PersistentObjectCancelEventArgs e) {
if (((DevExpress.XtraScheduler.AdvPersistentObjectCancelEventArgs)e).PropertyName == "LabelKey") {
}
}
Private Sub SchedulerStorage1_AppointmentChanging(ByVal sender As Object, ByVal e As PersistentObjectCancelEventArgs)
If CType(e, DevExpress.XtraScheduler.AdvPersistentObjectCancelEventArgs).PropertyName = "LabelKey" Then
End If
End Sub
For versions older than v18.1
This example illustrates how to determine whether or not the specific appointment property (the Appointment.LabelId in this example) value is changed without creating a Custom Appointment Form. We handle the SchedulerStorageBase.AppointmentChanging Event for this purpose and examine the e.Object's parameter value and the value returned by the PersistentObject.GetSourceObject Method. The first one represents a new value whereas the second one represents the previous value. Note that the GetSourceObject() method works even in unbound mode because in this mode a hidden data layer still exist in the Scheduler context (see Logical Layers). Here is a corresponding code snippet:
private void schedulerStorage1_AppointmentChanging(object sender, PersistentObjectCancelEventArgs e) {
int oldLabel = Convert.ToInt32(((DataRowView)((Appointment)e.Object).GetSourceObject((SchedulerStorageBase)sender)).Row["Label"]);
int newLabel = ((Appointment)e.Object).LabelId;
if (!newLabel.Equals(oldLabel))
MessageBox.Show("Label was changed!");
}
Note that a similar technique is used in the How to split appointments into groups example.