Spread for ASP.NET 8.0 Product Documentation > Developer's Guide > Using Sheet Models > Understanding the Models > Understanding the Selection Model |
The selection model includes any of the settings related to ranges of selected cells. This may include methods such as counting the number of selected ranges, adding and removing selections, clearing selections, and finding whether a cell is selected.
To use the underlying selection model, use the methods of the selection model. These include the SetSelection method, for setting cells as selected, and the AddSelection, ClearSelection, and RemoveSelection methods for adding, clearing, and removing selected ranges from the sheet. Refer to the Assembly Reference for more information on the selection model in general and to the DefaultSheetSelectionModel methods in particular.
The default implementation of the selection model (DefaultSheetSelectionModel) handles the selection of cells and ranges in the sheet, and stores the actual cell and range coordinates for each selection. The selection model handles the selection data, including computing the range being selected based on the cell clicked (the anchor cell) and the cell under the pointer.
Some events cause the anchor cell in the selection model to get set (for example, left mouse button down on a cell) so the selection model has the active cell as a selection. If you enter edit mode then cancel it by pressing the Esc key, or if you use the keyboard to move the active cell instead of the mouse, then the component might clear the selection model.
The selection model is saved to the view state only if it contains at least one selection.