Skip to main content
.NET 6.0+

View.SelectionChanged Event

Occurs after changing a View’s selected objects.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public event EventHandler SelectionChanged

Event Data

The SelectionChanged event's data class is EventArgs.

Remarks

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

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.1.dll assembly to References.

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.

See Also