Board index » delphi » How to save a richedit text (with formatting) in a Paradox-Database field (blob field)

How to save a richedit text (with formatting) in a Paradox-Database field (blob field)

Hello!

I've a richedit component in which the user can type in text and format it.
Now I want to save the "complete" (text & design) richedit in a database
field and later I want to show it again in a richedit. How to do that with
Delphi 3?

In my opinion is that to do with the Stream Methods, but I've no idea how to
apply them.

Thanks for any help,

Matthias.

 

Re:How to save a richedit text (with formatting) in a Paradox-Database field (blob field)


Hi Matthias,

Quote
>I've a richedit component in which the user can type in text and format it.
>Now I want to save the "complete" (text & design) richedit in a database
>field and later I want to show it again in a richedit. How to do that with
>Delphi 3?

>In my opinion is that to do with the Stream Methods, but I've no idea how to
>apply them.

Use the TBlobStream. Read esp. the examples for TStream.Read,
TBlobStream.Read in the OLH.

[untested - from scratch and from the OLH]

procedure TForm1.Button2Click(Sender: TObject);
var
  bs: TBlobStream;
begin
  bs:= TBlobStream.Create(
    Query1.FieldByName('Notes') as TBlobField, bmReadWrite);
  try
    RichEdit1.PlainText:= false;
    RichEdit1.Lines.SaveToStream(bs);
  finally
    bs.Free;
  end;
end;

Cheers,
   Udo
--
Homepage: http://www.nesshoever.de            No mails please. Reply here.

Delphi env.:                         Global Polio Awareness Campaign 2001+
W2K.sp1, D4Pro.sp3                       More info -> http://www.2-mad.com

Other Threads