Fires when row/cell selection is changed. In v21.1 and higher, the event fires both in single and multiple row selection modes.
NuGet Package: DevExpress.Win.Grid
[DXCategory("Property Changed")] public event SelectionChangedEventHandler SelectionChanged
<DXCategory("Property Changed")> Public Event SelectionChanged As SelectionChangedEventHandler
The SelectionChanged event's data class is SelectionChangedEventArgs. The following properties provide information specific to this event:
|Action||Gets an action which describes how the collection has been changed.|
|ControllerRow||Identifies the row whose selected state has been changed.|
Single Row Selection (view.OptionsSelection.MultiSelect option is false)
In v21.1 and higher, the following two events fire one after another when a row is focused (selected):
- ColumnView.FocusedRowChanged - This event’s arguments allow you to identify the previously and currently focused (selected) row.
- SelectionChanged - This event’s Action parameter returns the Refresh value, and the ControllerRow parameter returns the GridControl.InvalidRowHandle value.
You can handle these events interchangeably to respond to row selection changes. Use the ColumnView.GetSelectedRows method or ColumnView.FocusedRowHandle property to identify the currently focused (selected) row.
In versions prior to v21.1, the SelectionChanged event does not fire when a row receives focus.
Multiple Row Selection (view.OptionsSelection.MultiSelect option is true)
A user can select multiple rows or cells simultaneously when multiple row selection is active. The SelectionChanged event fires every time the row/cell selection is changed. If a specific row/cell is selected, the SelectionChanged event also fires every time the grid’s data is grouped and/or filtered.
Your business logic should not rely on the Action parameter. Values returned by this parameter may change in specific scenarios in the future. Currently, when rows are selected, the SelectionChanged event fires with the Action parameter set to Add or Refresh (depending on how rows are selected). When rows are deselected, the Action parameter returns either Remove or Refresh (depending on how rows are deselected).
The ControllerRow event parameter may return the GridControl.InvalidRowHandle property’s value when a single row is selected. It also returns this value after the selected row collection has been refreshed. For instance, this happens after the data has been grouped or filtered, or after a batch selection modification (see BaseView.BeginSelection).
See the following topics for more information:
Multiple row selection is disabled if cell merging is allowed (see GridOptionsView.AllowCellMerge).