Skip to main content
.NET Framework 4.5.2+

View.CurrentObjectChanged Event

Occurs after changing a View’s focused object (not an object’s property value).

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v22.1.dll

Declaration

public event EventHandler CurrentObjectChanged

Event Data

The CurrentObjectChanged event's data class is EventArgs.

Remarks

This event is raised in methods of the View class descendants:

Important

Do not mix a View’s focused object changes with property value changes. To track object instance’s changes, handle the IObjectSpace.ObjectChanged, INotifyPropertyChanged.PropertyChanged or other suitable events.

The following example demonstrates how to use the CurrentObjectChanged event to make a View read-only:

public class MyController : ViewController {
    protected override void OnActivated() {
        base.OnActivated();
        View.CurrentObjectChanged += View_CurrentObjectChanged;
        View_CurrentObjectChanged(View, new EventArgs());
    }
    private void View_CurrentObjectChanged(object sender, EventArgs e) {
       if (View.CurrentObject is Task) {
            View.AllowEdit["CurrentUser"] = ((Task)View.CurrentObject).Owner.Id == SecuritySystem.CurrentUserId;
       }
    }
    protected override void OnDeactivated() {           
        View.CurrentObjectChanged -= View_CurrentObjectChanged;
        base.OnDeactivated();
    }
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the CurrentObjectChanged 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