Board index » delphi » strip RTF from richedit

strip RTF from richedit

I need to strip all RTF from a table memo field and display the first line in
column of a dbgrid. Any help would be greatly appreciated.

Thanks,
Gene

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    

 

Re:strip RTF from richedit


Gene,

try this, i haven't tested it, it's just "written by the hand":

function stripRTF1stLine(RTFText: String): String;
var
  RE: TRichEdit;
  S: TStringStream;
begin
  Result := '';
  RE := TRichEdit.Create(Application.MainForm);
  RE.Parent := Application.MainForm;
  RE.Visible := false;
  RE.PlainText := true;
  S := TStringStream.Create(RTFText);
  RE.Lines.LoadFromStream(S);
  S.Free;
  { Result := RE.Text; }
  if (RE.Lines.Count > 0) then
    Result := RE.Lines[0];
  RE.Free;
end;

Hope this helps,
Ingo

efg...@my-dejanews.com schrieb in Nachricht
<7datjv$5a...@nnrp1.dejanews.com>...

Quote
>I need to strip all RTF from a table memo field and display the first line
in
>column of a dbgrid. Any help would be greatly appreciated.

>Thanks,
>Gene

>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own

Other Threads