<< Click to display table of contents >> Example: Using viewer-style methods in DBRichViewEdit |
This example shows how to use viewer-style methods in DBRichViewEdit (i.e. methods, introduced in TCustomRichView).
DBRichViewEdit1 edits a field of table Table1.We want to load RTF file.
procedure TForm1.Button1Click(Sender: TObject);
begin
if OpenDialog1.Execute and DBRichViewEdit1.CanChange then
begin
DBRichViewEdit1.Clear;
DBRichViewEdit1.LoadRTF(OpenDialog1.FileName);
DBRichViewEdit1.Change;
DBRichViewEdit1.Format;
end;
end;
Calling CanChange has the same effect as calling Table1.Edit.
If you want to save changes in the database immediately, call Table1.Post instead of DBRichViewEdit1.Format.
This sequence of actions (CanChange - modifications - Change - Format) is required only for viewer-style methods.
Editing-style methods do this work automatically:
procedure TForm1.Button2Click(Sender: TObject);
begin
if OpenDialog1.Execute then
DBRichViewEdit1.InsertRTFFromFileEd(OpenDialog1.FileName);
end;