Skip to main content
.NET 6.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.v23.2.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public event EventHandler<ObjectSpaceModificationEventArgs> ModifiedChanging

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ModifiedChanging event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also