rvico TRichView Reference | TRichView

TCustomRichView.GetOffsAfterItem

Top  Previous  Next

Returns offset after the ItemNo-th item in the document

function GetOffsAfterItem(ItemNo: Integer): Integer;

This method is useful for selecting part of document for copying in the Clipboard, or for moving caret to the specified position in editor.

ItemNo – index of the item. Items are indexed from 0 to ItemCount-1, GetItemStyle returns type of item. Items of subdocuments (table cells) are not included in the items range of the main document; for items in cells, use Cell.GetRVData.GetOffsAfterItem.

For text items, the method returns length of text + 1. The exception is empty text items formatted with style having EmptyWidth>0; for them, the position after the item is 2.

For non-text items, it returns 1.

 

Example for TRichViewEdit: moving caret to the end of document

var ItemNo, Offs: Integer;

 

  ItemNo := MyRichViewEdit.ItemCount-1;

  Offs := MyRichViewEdit.GetOffsAfterItem(ItemNo);

  MyRichViewEdit.SetSelectionBounds(ItemNo, Offs, ItemNo, Offs);

  MyRichViewEdit.Invalidate;

 

See also methods of TRichView:

SetSelectionBounds;

GetOffsBeforeItem.

See also properties of TRichView:

ItemCount.

See also properties of TRichViewEdit:

CurItemNo;

OffsetInCurItem.

See also:

Working with selection;

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


TRichView © trichview.com