trichview.com

trichview.support.examples




Re: DBRichViewEdit and "self-modified" controls


Return to index


Author

Message

Sergey Tkachenko

Posted: 04/12/2002 13:37:26


> 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?"


If the example with F1Book was too "exotic", below is the same case with

inserted TEdit.


How to work with TEdit inserted in TDBRichViewEdit, if you want to store its

text in RVF field.


1)  Add in the private section of form

procedure EditChange(Sender: TObject);


procedure TForm1.EditChange(Sender: TObject);

begin

  if DBRichViewEdit1.CanChange then

    DBRichViewEdit1.Change

  else

    Beep;

end;


where DBRichViewEdit1 is a TDBRichViewEdit containing TEdit


2) When creating a new TEdit, assign its OnChange event:


var Edit: TEdit;

begin

  Edit := TEdit.Create(nil);

  Edit.OnChange := EditChange;

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

end;


3) You'll need to assign this event to all edits 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 TEdit) then

    TEdit(ctrl).OnChange := EditChange;

end;


(

and of course, do not forget to register TEdit in the initialization section

of unit:

initialization

  RegisterClasses([TEdit]);

)







Powered by ABC Amber Outlook Express Converter