trichview.com

trichview.support.examples




DBRichViewEdit and "self-modified" controls


Return to index


Author

Message

Sergey Tkachenko

Posted: 01/29/2002 21:02:34


Q: "I can insert F1Book (an activeX bounded with delphi), type data, save it

and load it properly. However, in DBRichViewEdit,  all data in F1Book sheet

will lost when navigate dbase table. Would you please tell me how to do it?"


A:


This is an interesting example. F1Book allows user to modify itself, but

DBRichViewEdit does not know about these modifications, and they are not

saved in DB.

This problem can be solved. The solution for TF1Book is below. It can be

used as a sample for other components.


1)  Add in private section of form

procedure F1BookModified(Sender: TObject);


procedure TForm1.F1BookModified(Sender: TObject);

begin

  if DBRichViewEdit1.CanChange then

    DBRichViewEdit1.Change

  else

    Beep;

end;


where DBRichViewEdit1 is a TDBRichViewEdit containing F1Book.


2) When creating new book, assign its OnModified event:


var book: TF1Book;

begin

  book := TF1Book.Create(nil);

  book.OnModified := F1BookModified;

  DBRichViewEdit1.InsertControl('', book,rvvaBaseline);

end;


3) You'll need to assign this event to all books loaded from the database

field with RichView documents. Use OnControlAction of DBRichViewEdit:


procedure TForm1.DBRichViewEdit1ControlAction(Sender: TCustomRichView;

  ControlAction: TRVControlAction; ItemNo: Integer; var ctrl: TControl);

begin

  if (ControlAction=rvcaAfterRVFLoad) and (ctrl is TF1Book) then

    TF1Book(ctrl).OnModified := F1BookModified;

end;













Powered by ABC Amber Outlook Express Converter