Sardukar
Sardukar

Reputation: 247

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;

Upvotes: 1

Views: 468

Answers (1)

Sardukar
Sardukar

Reputation: 247

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.

Upvotes: 1

Related Questions