Skip to main content
.NET 6.0+

IObjectSpace.SetModified(Object) Method

Sets the state of the specified object to Modified and adds this object to the track list of changes that should be committed.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

void SetModified(
    object obj
)

Parameters

Name Type Description
obj Object

A persistent object whose IsModified state should be changed.

Remarks

If a data layer notification mechanism cannot track object changes, use the SetModified method. This method adds the object to the list of changes that should be committed.

In the BaseObjectSpace descendant, the BaseObjectSpace.SetModified method invokes the BaseObjectSpace.SetModified(Object obj, ObjectChangedEventArgs args) method. To change the object’s IsModified state, override the CreateObjectCore(Type type) method and return a new object of the type passed as the parameter.

You can raise the IObjectSpace.ObjectChanged event in your BaseObjectSpace.SetModified method override. The ObjectChanged event handler updates a Detail View’s Property Editor and a List View’s List Editor when their objects are changed.

The IObjectSpace.ModifiedObjects property contains objects in the Modified state.

The following example clears the Tasks collection of the Contact Detail View and marks the Contact object as modified:

using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.ExpressApp.Editors;
using MySolution.Module.BusinessObjects;
//...
namespace MySolution.Module.Controllers {
    public class ClearEmployeeTasksController : ViewController {
        private SimpleAction ClearTasksAction;
        public ClearEmployeeTasksController() {
            ClearTasksAction = new SimpleAction();
            ClearTasksAction.Execute += new SimpleActionExecuteEventHandler(ClearTasksAction_Execute);
        }

        private void ClearTasksAction_Execute(Object sender, SimpleActionExecuteEventArgs e) {
            while(((Employee)View.CurrentObject).Tasks.Count > 0) {
                ((Employee)View.CurrentObject).Tasks.Remove(((Employee)View.CurrentObject).Tasks[0]);
            }
            ObjectSpace.SetModified(View.CurrentObject);
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SetModified(Object) method.

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