Page 1 of 1

TDBRichView and corresponding database field update

Posted: Sat Jul 01, 2006 11:42 am
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.

Posted: Sat Jul 01, 2006 10:00 pm
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

Posted: Sun Jul 02, 2006 4:18 pm
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.