Search code examples
delphirave-reports

Trichedit to Rave memo buffer


How do I put formatted content of a TRichEdit into a Rave memo buffer, TMemoBuf?


Solution

  • You must use the Lines.SaveToStream function from the TRichEdit component to get the Formated text (rtf) and the use the TMemoBuf.RTFLoadFromStream function to load the rtf text into the TMemoBuf.

    var
      MemoryStream: TMemoryStream;
    begin
      MemoryStream:= TMemoryStream.Create;
      try
        //get the rtf data from the RichEdit into from the Memory stream
        RichEdit1.Lines.SaveToStream(MemoryStream);
        MemoryStream.Position := 0;
        //load the rtf data into the TMemoBuf
        MemoBuf1.RTFLoadFromStream(MemoryStream,0);
      finally
        MemoryStream.Free;
      end;
    end;