Insert text at the beginning of a TRichView

General TRichView support forum. Please post your questions here
Post Reply
Posts: 4
Joined: Sat Sep 21, 2019 1:35 pm

Insert text at the beginning of a TRichView

Post by Shouldercannon »

Please tell me how to insert text at the beginning of a TRichView

Sergey Tkachenko
Site Admin
Posts: 15169
Joined: Sat Aug 27, 2005 10:28 am

Re: Insert text at the beginning of a TRichView

Post by Sergey Tkachenko »

While TRichViewEdit has methods for insertion at the caret position, TRichView has only methods for adding to the end. The only exception is InsertRVFFromStream.
However, you can use the function from RVInsertItems.pas:

Code: Select all

procedure RVInsertString(RVData: TCustomRVData; ItemNo: Integer;
  const s: String; StyleNo, ParaNo: Integer; const Tag: TRVTag = RVEMPTYTAG);
To insert at the beginning, the parameter ItemNo must be 0, like:

Code: Select all

RVInsertString(RichView1.RVData, 0, 'Hello world!', 0, 0);
Please be careful when using this method, it may create an incorrect document when used incorrectly, see

PS: this unit also has a method for inserting a picture:

Code: Select all

procedure RVInsertGraphic(RVData: TCustomRVData; ItemNo: Integer;
  Graphic: TGraphic; Hyperlink: Boolean; ParaNo: Integer;
  VAlign: TRVVAlign = rvvaBaseline; const Tag: TRVTag = RVEMPTYTAG);

Post Reply