View.CurrentObjectChanged Event
Occurs after changing a View’s focused object (not an object’s property value).
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Event Data
The CurrentObjectChanged event's data class is EventArgs.
Remarks
This event is raised in methods of the View class descendants:
-
The CurrentObjectChanged event is raised after a currently displayed object (the DetailView.CurrentObject property value) is changed. For example, this occurs when you navigate to another object using the NextObjectAction or PreviousObjectAction.
-
The CurrentObjectChanged event is raised when the focused object is changed in a ListView.Editor.
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();
}
}
Related GitHub Examples
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.