Selection in Table

<< Click to display table of contents >>

Selection in Table

Types of Selection

Table can be:

not selected or

selected completely (as a part of larger selection) or

selected partially (multicell selection) or

some part of cell content (in cell or in inplace editor) selected.

RichView does not support selection started somewhere else and finished at the middle of a table. Selection containing several items can contain tables only completely (or it does not contain them).

Any method working with selection must be called only when the document is formatted.

Tables in Larger Selection

To determine if the table is selected completely, as a part of larger selection, use RichView.GetSelectionBounds (and compare its results with GetItemNo for table).

Multicell Selection

Table can be selected partially: selection can starts on one cell of table, and ends on another cell.

You can determine if the table selected partially using the methods TRVTableItemInfo.GetSelectionBounds or GetNormalizedSelectionBounds (the latter is more convenient).

You can select some cells in table using TRVTableItemInfo.Select and remove the selection using TRVTableItemInfo.Deselect.

You can select some rows or columns completely: TRVTableItemInfo.SelectRows and SelectCols.

You can determine if the given cell is selected or not with the method IsCellSelected.

Selection Inside Cell

You can get inplace-editor and position for currently edited cell: GetEditedCell.

See also: TRichViewEdit TopLevelEditor.

Before making selection inside cells, you need to activate inplace editor for it (TRichView does not have inplace editors, but the same code must be called in TRichView too, not only in TRichViewEdit).

Example 1 (selecting table.Cells[0,0]):

table.EditCell(0,0);

table.Cells[0,0].GetRVData.SelectAll;

Example 2 (does the same)

uses CRVData, CRVFData;

var RVData: TCustomRVData;

...

RVData := table.Cells[0,0];

RVData := RVData.Edit;

TCustomRVFormattedData(RVData).SelectAll;

The method in the second example (calling RVData := RVData.Edit, then selecting) can be used for any type of RVData, not only for table cells.

Editing Operations

Some RichViewEdit methods can be applied to the selected cells (regardless the type of selection):

ApplyTextStyle

ApplyParaStyle

ApplyStyleConversion

ApplyParaStyleConversion

DeleteSelection.