Page 1 of 1

TDBRichEdit and replacing tags with text on save/load

Posted: Tue Apr 24, 2007 8:06 am
by Ar4i
I have to make a template editor and I need to replace some text values with tags on load and then back to text on save (those text values represent certain queries and field in queries as well as some other things like cycles and formulaes that are not very user friendly).

My question is what are the most suitable TDBRichView events that can be used to modify contents of the RichView on LOAD and SAVE (especially from/to DB because I use TDBRichView).

Posted: Tue Apr 24, 2007 9:09 am
by Sergey Tkachenko
OnLoadDocument is called after the document is loaded from field, but before it is displayed (i.e. before DBRichView calls Format).
In this event you can do mail merging.

DBRichView cannot save documents in fields.

Posted: Tue Apr 24, 2007 10:16 am
by Ar4i
I might not have used the appropriate term, by saving to DB I ment that I save the template as single RichView document into a single DB Field (e.g. I just use the data aware TDBRichEdit). So basicly I also need a way to modify the document before saving it (e.g. before posting to db). Actually it turns out that I would need to display a modified version of what is stored into the DB, edit it and then store modified version again.

Posted: Tue Apr 24, 2007 11:07 am
by Sergey Tkachenko
If you make changes in the document using non-editing methods, call:
table.Edit;
dbrichviewedit.Change;
table.Post; // if you need to save changed immediately

Posted: Tue Apr 24, 2007 1:16 pm
by Ar4i
Actually the user makes changes and I would only need to replace things like //query12232:field22313// with tag [1] for example (on load) and then replace tag [1] back to text //query12232:field22313// on post. I'll try to use OnLoadDocument for the first and then BeforePost query event for the second.
Thanks for the help, your components will help me make one very nice template editor.