TCustomRichViewEdit.OffsetInCurItem (read-only)

<< Click to display table of contents >>

TCustomRichViewEdit.OffsetInCurItem (read-only)

Offset of the caret in the current item.

property OffsetInCurItem: Integer;

Index of item at the position of the caret is returned in CurItemNo property.

CurItemNo and OffsetInCurItem together define position of the caret in the document.

If item is a text item, then caret is before the OffsetInCurItem-th character of string. If caret is after the last character of the text item, OffsetInCurItem = length of the item + 1.

If item is not a text, then

if the caret is before the item, then OffsetInCurItem=0;

if the caret is after the item, then OffsetInCurItem=1.

If selection exists, position of the caret is always equal to the second bound of selection (because the caret is always at the end of selection).

You can set the caret position using SetSelectionBounds.

If the caret is inside table cell, this property returns 1 (position after the table). Items of subdocuments (table cells) are not included in the items range of the main document. If you want to know position of  the caret in the table cell, use TopLevelEditor.CurItemNo and TopLevelEditor.OffsetInCurItem.

This property must be accessed only when the document is formatted.

See also properties:

CurItemNo;

TopLevelEditor.

See also events:

OnCaretMove.

See also methods:

SetSelectionBounds;

GetSelectionBounds.

See also:

Inserting at the position of the caret;

How to: move the caret to the beginning or to the end of document in TRichViewEdit.