1 (edited by livexox 2019-01-17 02:29:29)

Topic: Rich Text Editor InsertTextA

Hello, can someone provide an example for RichEdit1.InsertTextA.


For example, i'm trying to insert a time stamp to a Rich Text Editor in bold and in red.  But I keep getting the error message

Incompatible Types: 'AnsiString', 'String'


procedure Form1_RichEdit1_OnKeyUp (Sender: TObject; var Key: Word; Shift, Alt, Ctrl: boolean);
begin

   if (Key=112) then
       begin
            frm_main.RichEdit1.InsertTextA('Time Stamp will be inserted here in bold and red',0);
       end;
end;

How can I insert formatted text to a RichText Box?

Re: Rich Text Editor InsertTextA

Please download latest version
https://www.dropbox.com/s/mb8hyuevvu8x5 … a.zip?dl=0


I have added new method to insert formated text

procedure InsertTextEx(const text: String; FontColor: TColor = -1; FontSize: integer = -1; FontStyles: Integer = -1; FontName: string = '');

Examples:

Form1.RichEdit1.InsertTextEx('Text', clRed);
Form1.RichEdit1.InsertTextEx('Text', clGreen, 30, fsBold+fsItalic+fsUnderline+fsStrikeOut, 'Arial'); 
 
Dmitry.

Re: Rich Text Editor InsertTextA

Is this fonction insert text in the same line or add a new line to the richedit?
If it insert in a new line. How to insert formated text in the same line ?

Re: Rich Text Editor InsertTextA

InsertText inserts text in the same line.

Dmitry.

5 (edited by einsteinf5 2019-01-20 22:30:21)

Re: Rich Text Editor InsertTextA

You can insert typed "enter" into the textRTF field, and a BOLD text like ...

Diagnostic.RichEdit1.TextRTF: = 'Error Code - \ r \ n' + # 13 + Diagnostic.EditDiagnostic.text + # 13 + 'Defect -' + # 13 # 10 + diagnostic.Memo1Diagnostic.text + 'Remedy / + diagnostic.Memo2Diagnostic.text + 'Comment -' + diagnostic.Memo3Diagnostic.text + 'Observations -' + diagnostic.SavObs.text;

Eventually a correction of this script, thank you!

Re: Rich Text Editor InsertTextA

Thank you very much