.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

Worksheet.GetSelectedRanges() Method

Returns cell ranges currently selected in the worksheet.

Namespace: DevExpress.Spreadsheet

Assembly: DevExpress.Spreadsheet.v21.2.Core.dll


IList<CellRange> GetSelectedRanges()


Type Description

A list of the CellRange objects.


The Worksheet.Selection property specifies the range of cells selected in the worksheet. The Worksheet.SelectedCell property specifies a single cell where data is inserted when an end-user types (in other words, this is an active cell). The Selection can be a single cell or contiguous or noncontiguous (union) range of cells, while the SelectedCell is always a single cell inside the current selection. If a cell you assign to SelectedCell is outside the currently selected range, the selection will be changed - it will coincide with the specified active cell.

You can also select multiple non-adjacent cells or cell ranges in the worksheet simultaneously. To get or set the list of ranges selected in the worksheet, use the GetSelectedRanges or Worksheet.SetSelectedRanges method, respectively. If there is more than one selected range in the worksheet (A2:C4, C6:C9, E3:F7, in the image below), the Worksheet.Selection property returns a complex (union) range that includes all the selected areas. You can access an individual range in the selection by its index in the CellRange.Areas collection.


To specify whether multi-selection is available to end-users in the SpreadsheetControl, use the SpreadsheetSelectionOptions.AllowMultiSelection option accessible via the SpreadsheetControl.Options.Behavior.Selection.AllowMultiSelection notation.


The Selection, SelectedCell, ActiveCell, SetSelectedRanges and GetSelectedRanges members of the SpreadsheetControl or SpreadsheetControl object allow you to manage cell selection in the worksheet that is currently active in the control.

See Also