从 D2005 升级到 D2010 : TRichEdit
以下代码在 D2005 上运行良好:
MyRichEdit1.Text := TMemoField(Query1.FieldByName('Msg')).asString;
但在 D2010 中,此代码以纯文本形式输出文本,而不是以 rtf 形式输出。
为了解决这个问题,我使用以下代码
MyRichEdit1.PlainText := False;
MyRichEdit1.Text := TMemoField(Query1.FieldByName('Msg')).asString;
MyRichEdit1.PlainText := TRUE;
MyRichEdit1.Lines.SaveToFile('Lixo.Rtf');
MyRichEdit1.PlainText := False;
MyRichEdit1.Lines.LoadFromFile('Lixo.Rtf');
如何将 rtf 文本从数据库导入到 TRichEdit,而无需在此过程中使用文件? 我尝试了该解决方案 这个问题 但它不起作用,它以纯文本形式出现,并且每个字符之间有一个空格。
谢谢 山姆
The following code works well on D2005 :
MyRichEdit1.Text := TMemoField(Query1.FieldByName('Msg')).asString;
But in D2010, this code outputs the text in plain text and not on rtf.
To solve the problem I'm using the following code
MyRichEdit1.PlainText := False;
MyRichEdit1.Text := TMemoField(Query1.FieldByName('Msg')).asString;
MyRichEdit1.PlainText := TRUE;
MyRichEdit1.Lines.SaveToFile('Lixo.Rtf');
MyRichEdit1.PlainText := False;
MyRichEdit1.Lines.LoadFromFile('Lixo.Rtf');
How can I import rtf text from a database to a TRichEdit without having to use a file in the process?
I tried the solution on
this question
but it doesn't work, it appear in plain text and with a space between each char.
Thanks
Sam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您尝试将 RTF 代码加载到
TRichEdit
中,请将 RTF 放入TStream
对象中,并使用 RichEdit 的LoadFromStream()
方法PlainText
属性设置为 False。If you are trying to load RTF code into a
TRichEdit
, then place the RTF into aTStream
object and use the RichEdit'sLoadFromStream()
method with thePlainText
property set to False.该解决方案适用于 C++ Builder XE,但类似的解决方案也可用于 Delphi。
This solution is for C++ Builder XE, but analogous could be used for Delphi.