.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET 5.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.v21.2.dll

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 MySolution.Module.BusinessObjects;
//...
private void ClearTasksAction_Execute(Object sender, SimpleActionExecuteEventArgs e) {
    while(((Contact)View.CurrentObject).Tasks.Count > 0) {
        ((Contact)View.CurrentObject).Tasks.Remove(((Contact)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