How use the TRVStyle for save and load format text?

General TRichView support forum. Please post your questions here
Post Reply
greatsea
Posts: 14
Joined: Sat Nov 05, 2011 5:54 pm

How use the TRVStyle for save and load format text?

Post by greatsea »

Edit the text in RichViewEdit,and save them into DB.
Now,the text data is include a variety of font,size,bold,etc.
Load it from DB,the text will become the only "normal text",not is the rich text.
How to make the load text to become original rich text?
Thanks.
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Do you use TRichViewEdit, not TDBRichViewEdit?
If yes, how do you save and load it in DB?
greatsea
Posts: 14
Joined: Sat Nov 05, 2011 5:54 pm

Post by greatsea »

yes,use RichViewEdit.

Save:
rve.SaveRVFToStream(TS,False);

then insert the stream data into DB,all is OK.

Load:
TS := TStringStream.Create(DBMSG);
try
TS.Position := 0;
rve.InsertRVFFromStream(TS, rve.ItemCount);
rve.FormatTail;
finally
TS.Free;
end;
Sergey Tkachenko
Site Admin
Posts: 17572
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Make sure that rvfoSaveTextStyles and rvfoSaveParaStyles are included in rve.RVFOptions, and rve.RVFTextStylesReadMode=rve.RVFParaStylesReadMode=rvf_sInsertMerge

PS: it's better to use TMemoryStream instead of TStringStream
PPS: if you load using rve.InsertRVFFromStream, do not forget to call rve.Clear before. But you can load using rve.LoadRVFFromStream instead.
Post Reply