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

<< Click to display table of contents >>

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

Option 1

Moving to the beginning:

MyRichViewEdit.MoveCaret(rvcmTop);

Moving to the end:

MyRichViewEdit.MoveCaret(rvcmBottom);

Option 2

The caret is always at the end of selection.

Selection can be changed using method TRichViewEdit.SetSelectionBounds.

Moving to the beginning:

var

  ItemNo, Offs: Integer;

...

ItemNo := 0;

Offs   := MyRichViewEdit.GetOffsBeforeItem(ItemNo);

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

Moving to the end:

var

  ItemNo, Offs: Integer;

...

ItemNo := MyRichViewEdit.ItemCount-1;

Offs   := MyRichViewEdit.GetOffsAfterItem(ItemNo);

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

 

See also:

TRichViewEdit.CurItemNo and OffsetInCurItem;

Example how to move caret to the beginning of paragraph.