Back to Devexpress

DetailView.CurrentObject Property

expressappframework-devexpress-dot-expressapp-dot-detailview.md

latest4.6 KB
Original Source

DetailView.CurrentObject Property

Specifies an object displayed by the Detail View.

Namespace : DevExpress.ExpressApp

Assembly : DevExpress.ExpressApp.v25.2.dll

NuGet Package : DevExpress.ExpressApp

Declaration

csharp
public override object CurrentObject { get; set; }
vb
Public Overrides Property CurrentObject As Object

Property Value

TypeDescription
Object

An Object displayed by the Detail View.

|

Remarks

The example below demonstrates how to assign a Contact ‘s FirstName value to the NickName property via a SimpleAction only in Detail Views.

csharp
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using MainDemo.Module.BusinessObjects;
// ...
public class SetNickNameController : ViewController<DetailView> {
    public SetNickNameController() {
        SimpleAction setNickNameAction = new SimpleAction(this, "SetNickName", PredefinedCategory.Edit);
        setNickNameAction.Execute += SetNickNameAction_Execute;
    }
    private void SetNickNameAction_Execute(object sender, SimpleActionExecuteEventArgs e) {
        Contact currentObject = View.CurrentObject as Contact;
        if(currentObject != null) {
            currentObject.NickName = currentObject.FirstName;
        }
    }
}

By default, this property is set to the object that was passed in the Detail View constructor. You can change it. This will raise the View.SelectionChanged, View.CaptionChanged and View.CurrentObjectChanged events one after another.

For additional information, refer to the How to: Access Objects Selected in the Current View help topic.

The following code snippets (auto-collected from DevExpress Examples) contain references to the CurrentObject property.

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.

XAF-search-objects-using-complex-criterion/CS/EFCore/ComplexSearchEF/ComplexSearchEF.Module/Controllers/MySearchController.cs#L14

csharp
private void MyAction1_Execute(object sender, SimpleActionExecuteEventArgs e) {
    var mySearchObject = (MySearchClass)View.CurrentObject;
    var persistentOS = Application.CreateObjectSpace(typeof(Contact));

XAF_how-to-show-filter-dialog-before-listview/CS/EFCore/DialogBeforeListViewEF/DialogBeforeListViewEF.Module/Controllers/ShowFilterDialogController.cs#L45

csharp
filterDetailView.ObjectSpace.CommitChanges();
ViewFilterContainer currentViewFilterContainer = (ViewFilterContainer)filterDetailView.CurrentObject;
((IModelListViewAdditionalCriteria)View.Model).AdditionalCriteria = currentViewFilterContainer.Criteria;

See Also

ListView.CurrentObject

DetailView.SelectedObjects

DetailView Class

DetailView Members

DevExpress.ExpressApp Namespace