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)


Quote
"Matthias Meinecke" <matth...@netmediasystems.de> wrote in message

news:9hn81g$5a1$1@news.online.de...

Quote
> 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.

The simplest method would be to use a tDBRichEdit control. If that isn't an
option the the code below should do the trick.

procedure LoadRTEFromField (aField : tBlobField; anRTE : tRichEdit);

var    bs : tBlobStream;

begin
bs := tBlobStream.Create (aField, bmRead);
try
    anRTE.Lines.LoadFromStream (bs);
finally
    bs.Free;
    end;
end;

procedure SaveRTEToField (anRTE : tRichEdit; aField : tBlobField);

var bs : tBlobStream;

begin
bs := tBlobStream.Create (aField, bmWrite);
try
    anRTE.Lines.SaveToStream (bs);
finally
    bs.Free;
    end;
end;

Other Threads