TCustomRichView.GetOffsBeforeItem

<< Click to display table of contents >>

TCustomRichView.GetOffsBeforeItem

Returns offset before the ItemNo-th item in the document

function GetOffsBeforeItem(ItemNo: Integer): Integer;

This method is useful for selecting a 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.GetOffsBeforeItem.

For text items, the method returns 1 For non-text items, it returns 0.

 

Example for TRichViewEdit: moving caret to the beginning of document

var ItemNo, Offs: Integer;

 

  ItemNo := 0;

  Offs := MyRichViewEdit.GetOffsBeforeItem(ItemNo);

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

  MyRichViewEdit.Invalidate;

 

See also methods of TRichView:

SetSelectionBounds;

GetOffsAfterItem.

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;

Example how to move caret to the beginning of paragraph.