RichText showing control characters
Hi,
I assign as follows:
rtCompanyDetail.RichText := sysCompanyDetail.AsString;
where trCompanyDetail is a RichText component and sysCompanyDetail is a
variable (calc). The calc variable holds a string which contains rtf codes.
Upon assigning this to the RichText, I would have thought the richtext
component would decipher those codes and display accordingly. However, it
doesnt, it displays the whole string including the control characters.
Is there a way to handle this so that the rtf codes are interpreted
correctly?
Thanks
Alex
I assign as follows:
rtCompanyDetail.RichText := sysCompanyDetail.AsString;
where trCompanyDetail is a RichText component and sysCompanyDetail is a
variable (calc). The calc variable holds a string which contains rtf codes.
Upon assigning this to the RichText, I would have thought the richtext
component would decipher those codes and display accordingly. However, it
doesnt, it displays the whole string including the control characters.
Is there a way to handle this so that the rtf codes are interpreted
correctly?
Thanks
Alex
This discussion has been closed.
Comments
read in Word or WordPad?
Here is my code that tests what you described:
procedure TForm1.Button1Click(Sender: TObject);
begin
ppReport1.Print;
end;
procedure TForm1.ppVariable1Calc(Sender: TObject; var Value: Variant);
begin
Memo1.Lines.LoadFromFile('C:\zsdv.rtf');
Value := Memo1.Lines.Text;
end;
procedure TForm1.ppRichText1Print(Sender: TObject);
begin
ppRichText1.RichText := ppVariable1.Value;
end;
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
I'm still stuck on this. I do not want to load from file. I have a
richtext component on a screen. The user can enter any rich text into this
component. I then want to translate the contents of this into a report
richtext component for viewing in a report. How can I do this?
Regards
Alex
Cheers,
Jim Bennett
Digital Metaphors
------------------------------------------------
Tech Tip: Copy RTF data from TRichEd to TppRichText
------------------------------------------------
You can copy RTF data from Delphi's TRichEd to ReportBuilder's TppRichText
control by using an intermediate memory stream:
var
lRTFStream: TMemoryStream;
begin
{create temp memory stream}
lRTFStream := TMemoryStream.Create;
{save the TRichEd's rtf data to the memory stream}
RichEdit1.Lines.SaveToStream(lRTFStream);
{load the rtf stream to the TppRichText}
lRTFStream.position := 0;
ppRichText1.LoadFromRTFStream(lRTFStream);
{free the memory stream}
lRTFStream.Free;
end;
Note: An alternative method would be to use RichEdit1.Lines.SaveToFile and
TppRichText.LoadFromFile.
--
Tech Support mailto:support@digital-metaphors.com
Digital Metaphors http://www.digital-metaphors.com
http://www.digital-metaphors.com
info@digital-metaphors.com
Thanks for that, I almost had it previously, problem is I didn't set the
stream position back to zero before saving. The example really helped.
Thanks again
Alex