<< Click to display table of contents >>


Returns selection in table in convenient form.

function GetNormalizedSelectionBounds(IncludeEditedCell: Boolean;

         out TopRow, LeftCol, ColSpan, RowSpan: Integer): Boolean;

Input parameter:

If IncludeEditedCell = True, this function returns position of the currently edited cell (if there is no selection and some cell is currently in editing state).

Output parameters:

TopRow, TopCol receive the top left corner of the selection (warning: selection is not always rectangular!)

ColSpan, RowSpan how many columns and rows the selection includes. Both values are >= 1.

Warning: it will be wrong to iterate through selected cells as:

for r := TopRow to  TopRow+RowSpan-1 do

  for c := LeftCol to TopCol+ColSpan-1 do

    if table.Cells[r,c]<>nil then ...

This cycle can miss some selected cells, because there can be some cells to the left of LeftCol and to the top of TopRow, which are also in selection because of spanning.

The correct example is in the topic about IsCellSelected.

Some operations are possible only on rectangular selection (for example, cell merging). It can be checked using CanMergeSelectedCells.

This method must be called when the document is formatted.

Return value:

True, if selection exists, False otherwise.

See also:

Overview of selection in tables

See also methods: