TDBRichView and corresponding database field update

General TRichView support forum. Please post your questions here
Post Reply
Sergius
Posts: 1
Joined: Sat Jul 01, 2006 11:37 am

TDBRichView and corresponding database field update

Post by Sergius »

My app has TDBRichView (of course, with database field associated with it). When I load content of RV from file - it showed correctly.

But how I can update database field with this new content? I try this code:

NotesTable->Edit();
DBRichViewEdit->Change();
NotesTable->Post();

But it does not work.
Michel
Posts: 92
Joined: Fri Oct 14, 2005 2:56 pm
Contact:

Post by Michel »

I think you are missing a call to DBRichViewEdit->CanChange(). If performing programmatic edits, you'd want to call:
NotesTable->Edit();
if (!DBRichViewEdit->CanChange())
; // Bail out gracefully
// This is where, I guess, you'd change the contents
DBRichViewEdit->Change();
NotesTable->Post();

If the idea is to simply allow the end-user to edit text interactively, I don't believe you need to call anything. Just treat DBRichViewEdit as you'd treat a TDBEdit or similar.

Good luck!

Michel
Sergey Tkachenko
Site Admin
Posts: 17310
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Actually, DBRichViewEdit->CanChange() calls table->Edit().
Calling CanChange() & Change() is required only if DBRichViewEdit was modified using non-editing methods (such as Load** or Add*** methods).
CanChange() & Change() are not required if the document was modified using editing methods (all methods introduced in TCustomRichViewEdit, marked in the help file as "editing-style methods"), or directly by the user (typing, etc.).
In this case, NotesTable->Post() is enough.
Post Reply