The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

View.SelectionChanged Event

Occurs after changing a View's selected objects.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v19.2.dll

Declaration

public event EventHandler SelectionChanged
Public Event SelectionChanged As EventHandler
public event EventHandler SelectionChanged
Public Event SelectionChanged As EventHandler
public event EventHandler SelectionChanged
Public Event SelectionChanged As EventHandler

Event Data

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

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

See Also