简体   繁体   中英

Append formated text from SQL to TRichEdit

Can you help with this problem? How do I append a formatted txt from database field to a TRichEdit ?

Just to clarify: I need to get the contents of 2 database fields that have formatted text (RTF) and put them in TrichEdit preserving the formatting. I use MSSQL Express and the field are set as TEXT in ANSI format.

Ok this works nice:

  tmp := tblCases.FieldByName('Field1').AsString;
  str := tblCases.FieldByName('Field2').AsString;
  delete (tmp,LastDelimiter ('}',tmp),1);
  delete (str,1,1);
  ms := TStringStream.Create (tmp+ AnsiSTRing (#13#10)+str);
  ms.Position :=0;
  DBDX.Lines.LoadFromStream(MS);
  ms.Free;

To merge 2 RTF fields I removed the last closing } of the first and the first bracket of the second thus creating one string. then use the TstringStream to paste in the TrichEdit. see updated code above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM