Skip to main content
.NET 8.0+

DevExpress v25.1 Update — Your Feedback Matters

Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

CloneObjectViewController.CustomShowClonedObject Event

Occurs before XAF displays the Detail View of the cloned object.

Namespace: DevExpress.ExpressApp.CloneObject

Assembly: DevExpress.ExpressApp.CloneObject.v25.1.dll

#Declaration

public event EventHandler<CustomShowClonedObjectEventArgs> CustomShowClonedObject

#Event Data

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

Property Description
ClonedObject Gets the target cloned object.
Handled Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing. Inherited from HandledEventArgs.
ShowViewParameters Gets a set of parameters used to display a cloned object’s Detail View.
SourceObject Gets the source cloned object.
TargetObjectSpace Specifies the Object Space of the target cloned object.

#Remarks

XAF displays the Detail View of the cloned object after cloning. Handle this event to implement the custom code to be executed before or instead of displaying the Detail View. Set the handler’s Handled parameter to true to prohibit displaying the Detail View.

The following code snippet adds the cloned object to the current List View instead of displaying it in the Detail View. Note that the code only works when the current View is an editable List View. The default behavior persists when the current View is a Detail View or non-editable List View.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.CloneObject;
using DevExpress.Persistent.BaseImpl.EF;
using Microsoft.EntityFrameworkCore.Metadata;

namespace YourApplicationName.Module.Controllers;

public class MyCloneObjectController : CloneObjectViewController  {
    // ...
    protected override void OnActivated() {
        base.OnActivated();
        this.CustomShowClonedObject +=
            new EventHandler<CustomShowClonedObjectEventArgs>(
                MyCloneObjectController_CustomShowClonedObject);
    }
    private void MyCloneObjectController_CustomShowClonedObject(
        object sender, CustomShowClonedObjectEventArgs e) {
        if ((View is ListView) && (View.AllowEdit.ResultValue)) {
            e.TargetObjectSpace.CommitChanges();
            ((ListView)View).CollectionSource.Add(ObjectSpace.GetObject(e.ClonedObject));
            e.Handled = true;
        }
    }
}
See Also