The requested page is not available for the requested platform. You are viewing the content for Default platform.

View.CurrentObjectChanged Event

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

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v18.2.dll

Declaration

public event EventHandler CurrentObjectChanged
Public Event CurrentObjectChanged As EventHandler

Event Data

The CurrentObjectChanged event handler receives an argument of the EventArgs type.

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();
    }
}
See Also