View.SelectionChanged Event
Occurs after changing a View's selected objects.
Namespace: DevExpress.ExpressApp
Assembly: DevExpress.ExpressApp.v20.2.dll
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.v20.2.dll assembly to References.
Implements
DevExpress.ExpressApp.ISelectionContext.SelectionChanged
See Also
Feedback