View.SelectionChanged Event
Occurs after changing a View’s selected objects.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v24.2.dll
NuGet Package: DevExpress.ExpressApp
Declaration
Event Data
The SelectionChanged event's data class is EventArgs.
Remarks
This event is raised in methods of the View class descendants:
-
The SelectionChanged event occurs after changing the current object as a result of setting a value to the DetailView.CurrentObject method.
-
The SelectionChanged event is raised when the selected objects are changed in the ListView.Editor.
The example below demonstrates how to change a SimpleAction‘s caption when the selected object changes.
using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Actions;
using DevExpress.Persistent.Base;
using MainDemo.Module.BusinessObjects;
// ...
public class ActionCaptionController : ViewController {
private SimpleAction objectAction;
private void UpdateActionCaption() {
objectAction.Caption = CalculateActionCaption();
}
private string CalculateActionCaption() {
Contact currentObject = (Contact)View.CurrentObject;
if(currentObject != null) {
return currentObject.FullName;
}
return "Object Action";
}
private void View_SelectionChanged(object sender, EventArgs e) {
UpdateActionCaption();
}
protected override void OnActivated() {
base.OnActivated();
UpdateActionCaption();
View.SelectionChanged += View_SelectionChanged;
}
protected override void OnDeactivated() {
View.SelectionChanged -= View_SelectionChanged;
base.OnDeactivated();
}
public ActionCaptionController() {
TargetObjectType = typeof(Contact);
objectAction = new SimpleAction(this, "ObjectAction", PredefinedCategory.Edit);
}
}
Note
To run this code, add the DevExpress.ExpressApp.XtraGrid.v24.2.dll assembly to References.
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SelectionChanged 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.