Page 1 of 1

How use the TRVStyle for save and load format text?

Posted: Wed Dec 07, 2011 10:42 am
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.

Posted: Wed Dec 07, 2011 5:24 pm
by Sergey Tkachenko
Do you use TRichViewEdit, not TDBRichViewEdit?
If yes, how do you save and load it in DB?

Posted: Thu Dec 08, 2011 2:05 pm
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;

Posted: Thu Dec 08, 2011 2:29 pm
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.