SharpCell.Grid

GridSelection

public sealed class GridSelection

Namespace SharpCell.Grid · package SharpCell.Grid

The selected cells, as in Excel: a rectangle of cells and the active cell inside it. The rectangle runs from the GridSelection.Anchor, where the selection started, to the GridSelection.Extent, the corner the mouse or Shift with the arrows moves, and grows to cover whole every merged area it touches. Whole columns span every row of the sheet, whole rows every column. A selection never changes; each step gives a new one.

Properties

ActiveCell

public CellPosition ActiveCell { get; }

The cell typing would go into, with the white background inside the shaded selection.

Anchor

public CellPosition Anchor { get; }

The corner the selection started from; it stays when the selection is extended.

Area

public CellArea Area { get; }

The selected cells, merged areas they touch included.

Extent

public CellPosition Extent { get; }

The corner opposite the anchor, which extending the selection moves.

IsEntireColumns

public bool IsEntireColumns { get; }

Whether the selection spans every row: whole columns, or the whole sheet.

IsEntireRows

public bool IsEntireRows { get; }

Whether the selection spans every column: whole rows, or the whole sheet.

IsSingleCell

public bool IsSingleCell { get; }

Whether only the active cell is selected; a merged area counts as one cell.

Methods

All(CellPosition)

public static GridSelection All(CellPosition activeCell)

The whole sheet, keeping the active cell where it is.

At(GridHit, Worksheet)

public static GridSelection At(GridHit hit, Worksheet? sheet)

What a click selects: a cell, whole columns from a column header, whole rows from a row header, the whole sheet from the corner above the row headers.

Cell(CellPosition, Worksheet)

public static GridSelection Cell(CellPosition cell, Worksheet? sheet)

One cell, or the merged area holding it.

Columns(int, int, int, Worksheet)

public static GridSelection Columns(int first, int last, int activeRow, Worksheet? sheet)

Whole columns, from the first to the last, with the active cell in the first column.

Parameters

Contains(int, int)

public bool Contains(int row, int column)

Whether a cell is selected.

EntireColumns(Worksheet)

public GridSelection EntireColumns(Worksheet? sheet)

Whole columns under the selection, keeping the active cell, as Ctrl+Space does.

EntireRows(Worksheet)

public GridSelection EntireRows(Worksheet? sheet)

Whole rows under the selection, keeping the active cell, as Shift+Space does.

Extend(int, int, Worksheet)

public GridSelection Extend(int rows, int columns, Worksheet? sheet)

The selection grown or shrunk by whole rows and columns at its extent, as Shift with the arrows does; a step that a merged area swallows goes on until the selection changes.

ExtendTo(CellPosition, Worksheet)

public GridSelection ExtendTo(CellPosition cell, Worksheet? sheet)

The selection from the same anchor to a cell, as when dragging the mouse or Shift-clicking: whole columns or rows stay whole, the active cell stays.

ExtendTo(GridHit, Worksheet)

public GridSelection ExtendTo(GridHit hit, Worksheet? sheet)

The selection from the same anchor to what a Shift-click hits: to a cell, to whole columns from a column header, to whole rows from a row header, the whole sheet from the corner.

ExtendToEdge(int, int, Worksheet)

public GridSelection ExtendToEdge(int rows, int columns, Worksheet? sheet)

The selection extended from its far corner to the edge of the content, as Ctrl+Shift with an arrow does.

Parameters

Move(int, int, Worksheet)

public GridSelection Move(int rows, int columns, Worksheet? sheet)

The active cell moved by whole rows and columns, as the arrows move it, and selected alone.

MoveToEdge(int, int, Worksheet)

public GridSelection MoveToEdge(int rows, int columns, Worksheet? sheet)

The active cell moved to the edge of the content, as Ctrl with an arrow moves it, and selected alone.

Parameters

MoveWithin(int, int, Worksheet)

public GridSelection MoveWithin(int rows, int columns, Worksheet? sheet)

The active cell moved as Enter and Tab move it. A single cell moves as with the arrows; inside a larger selection it moves to the next cell of the selection, which stays, and wraps around: Enter goes down each column in turn, Tab across each row. Hidden cells and the inner cells of merged areas are passed over.

Parameters

Rows(int, int, int, Worksheet)

public static GridSelection Rows(int first, int last, int activeColumn, Worksheet? sheet)

Whole rows, from the first to the last, with the active cell in the first row.

Parameters

SelectAll(Worksheet)

public GridSelection SelectAll(Worksheet? sheet)

What Ctrl+A selects, as in Excel: first the current region around the active cell (see GridNavigation.CurrentRegion), then, pressed again, the whole sheet. An empty cell with nothing around it, or a lone cell, goes straight to the whole sheet. The active cell stays.

Parameters

ToString()

public override string ToString()

The selected cells' address: B3, B3:D7, C:E for whole columns, 2:4 for whole rows.