Page 1 of 1

How RichEdit to RichView

Posted: Sun Sep 27, 2015 5:03 pm
by miwan
Hi
I hope your help to copy text from a RichEdit (Delphi IDE) in a RichView (component TRichView).
If possible what is the procedure.
I did like that
RichView1.text := RichEdit1.text ; ---- Error :oops:
RichView1.ADDNL := RichEdit1.text ; ----Error :oops:

I thank all the help

Posted: Mon Sep 28, 2015 6:58 am
by SpoQSI
I havenĀ“t tested it yet, but you might try:

Code: Select all

procedure CopyFromRichEditToRichView();
    var strStream: TStringStream;
begin
    RichEdit1.Lines.SaveToStream(strStream);
    RichView1.LoadRTFFRomStream(strStream);
end;

Posted: Mon Sep 28, 2015 8:27 am
by Sergey Tkachenko
More exactly

Code: Select all

procedure CopyRichEditToRV(RichEdit: TRichEdit; RichView: TCustomRichView);
var Stream: TMemoryStream;
begin
  Stream := TMemoryStream.Create;
  try
    RichEdit.Lines.SaveToStream(Stream);
    Stream.Position := 0;
    RichView.Clear;
    RichView.LoadRTFFromStream(Stream);
    RichView.Format;
  finally
    Stream.Free;
  end;
end;
Make sure that RichEdit.PlainText = False;

Posted: Mon Sep 28, 2015 9:24 am
by miwan
thank you for this quick response that's perfect .
but another solution that stream?

Posted: Mon Sep 28, 2015 9:31 am
by Sergey Tkachenko
Sorry, I do not understand this question, please ask in other words.

Posted: Mon Sep 28, 2015 9:56 am
by miwan
dear ali
This is good it is concluded
thank you a lot

Posted: Mon Sep 28, 2015 9:58 am
by miwan
Correction: ali = all (Sergey, SpoQSI) .