rvico TRichView Reference | TRichView

TCustomRichView.SetSelectionBounds

Top  Previous  Next

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).
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).
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.

 

In TRichViewEdit, the caret is always at the end of the selection, so this method can be used to move caret.

 

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.

This method does not repaint 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.

 

See also methods:

SelectAll;
Deselect;
GetSelectionBounds.

See also events:

OnSelect.

See also:

Working with selection;
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.


RichView © Sergey Tkachenko