All docs
V20.1
20.2 (EAP/Beta)
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

BaseObjectSpace.ModifiedChanging Event

Occurs before the IsModified property is changed to true. Handle this event to cancel or force the IsModified property to change.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v20.1.dll

Declaration

public event EventHandler<ObjectSpaceModificationEventArgs> ModifiedChanging
Public Event ModifiedChanging As EventHandler(Of ObjectSpaceModificationEventArgs)

Event Data

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

Property Description
Cancel Specifies whether the IsModified property change must be canceled.
MemberInfo Specifies an object that is information on the property whose value has been changed. Inherited from ObjectChangedEventArgs.
NewValue Specifies the new value of a changed property. Inherited from ObjectChangedEventArgs.
Object Provides access to the object that is being manipulated. Inherited from ObjectManipulatingEventArgs.
OldValue Specifies the old value of a changed property. Inherited from ObjectChangedEventArgs.
PropertyName Specifies the name of a property whose value has been changed. Returns null (Nothing in VB) if it is impossible to determine what property causes the change. Inherited from ObjectChangedEventArgs.

Remarks

The following example shows how to cancel the IsModified property change when you modify the Category property of a ProductView object. In this case, the current Object Space does not add this object to the ModifiedObjects collection.

using System;
using DevExpress.ExpressApp;
// ...
public sealed partial class MySolutionModule : ModuleBase {
    // ...
    public override void Setup(XafApplication application) {
        base.Setup(application);
        application.SetupComplete += Application_SetupComplete;
    }
    private void Application_SetupComplete(object sender, EventArgs e) {
        Application.ObjectSpaceCreated += Application_ObjectSpaceCreated;
    }
    private void Application_ObjectSpaceCreated(object sender, ObjectSpaceCreatedEventArgs e) {
        var npos = e.ObjectSpace as NonPersistentObjectSpace;
        if(npos != null) {
            npos.ModifiedChanging += ObjectSpace_ModifiedChanging;
        }
    }
    private void ObjectSpace_ModifiedChanging(object sender, CancelObjectChangedEventArgs e) {
        if(e.MemberInfo!= null) {
            if(e.MemberInfo.Owner.Type == typeof(ProductView) && 
            e.MemberInfo.Name == nameof(ProductView.Category)) {
                e.Cancel = true;
            }
        }
    }
}
See Also