1

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;
Sardukar
  • 247
  • 6
  • 16
  • `.SelText := 'I am appended if .SelStart := .GetTextLen' and blue if SelAttributes.Color := clBlue;` – Alex K. Jun 27 '14 at 11:25
  • 'Formatted text'? In what format is the text? In what field type is it stored (and in what database)? – Jan Doggen Jun 27 '14 at 11:33
  • I did try that however it will just paste a plain text. I tried to switch off the plain text like rtf.plaintext :=false and use stream but will just replace the text the RtF. i need formatting to be preserved. – Sardukar Jun 27 '14 at 11:34

1 Answers1

1

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.

Sardukar
  • 247
  • 6
  • 16