Skip to main content

ColumnView.SelectionChanged Event

Fires when row/cell selection is changed. In v21.1 and higher, the event fires both in single and multiple row selection modes.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v23.2.dll

NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

[DXCategory("Property Changed")]
public event SelectionChangedEventHandler SelectionChanged

Event Data

The SelectionChanged event's data class is SelectionChangedEventArgs. The following properties provide information specific to this event:

Property Description
Action Gets an action which describes how the collection has been changed.
ControllerRow Identifies the row whose selected state has been changed.

Remarks

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):

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).

To obtain currently selected rows and cells, use the ColumnView.GetSelectedRows and GridView.GetSelectedCells methods.

See the following topics for more information:

Note

Multiple row selection is disabled if cell merging is allowed (see GridOptionsView.AllowCellMerge).

The following code snippets (auto-collected from DevExpress Examples) contain references 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