<< Click to display table of contents >> TCustomRichView.SetSelectionBounds |
Selects part of RichView document (for copying to the Clipboard)
procedure SetSelectionBounds(StartItemNo, StartItemOffs,
EndItemNo, EndItemOffs: Integer);
Parameters
StartItemNo – index of the first selected item.
StartItemOffs:
▪if the first item is a text item, then the selection start is before the StartItemOffs-th character of string (characters in strings are counted from 1, the last position (after the text item) is text length+1). The exception is empty text items formatted with style having EmptyWidth>0; for them, the position after the item is 2.
▪if the first item is not a text, then
•if StartItemOffs=0, then the selection start is before the first item;
•if StartItemOffs=1, then the selection start is after the first item.
EndItemNo – index of the last selected item.
EndItemOffs:
▪if the last item is a text item, then the selection end is before the EndItemOffs-th character of string (characters in strings are counted from 1, the last position (after the text item) is text length+1). The exception is empty text items formatted with style having EmptyWidth>0; for them, the position after the item is 2.
▪if the last item is not a text, then
•if EndItemOffs=0, then the selection end is before the last item
•if EndItemOffs=1, then the selection end is after the last item.
Caret position
In TRichViewEdit, the caret is always at the end of the selection, so this method can be used to move caret.
Selection in table cells
Before making selecting inside a table cell, activates its editing:
var RVData: TCustomRVFormattedData;
RVData := TCustomRVFormattedData(Table.Cells[r,c].Edit);
RVData.SetSelectionBounds(...);
Deselection
There are two ways to deselect:
▪to pass StartItemNo=-1
▪to pass StartItemNo=EndItemNo and StartItemOffs=EndItemOffs (in editor, the caret is moved to the specified position).
Please be careful and do not specify incorrect values.
Additional information
This method does not repaint the component (use Invalidate)
This method generates OnSelect event.
There are two useful methods to work with SetSelectionBounds: GetOffsBeforeItem and GetOffsAfterItem.
This method must be called only when the document is formatted.
If you want to set selection bounds using richedit-like parameters (SelStart and SelLength), use RVSetSelection from RVLinear unit instead.
See also methods:
▪Deselect;
See also events:
▪OnSelect.
See also:
▪How to: move a caret to the beginning or to the end of document in TRichViewEdit;
▪Example how to move caret to the beginning of paragraph.
See also:
▪Edit method of table cell.