Automatically Display Memo Editor on New Record

I am using an InfoPower TwwDBGrid and wish to display the memo editor automatically when a new record is added.  Anyone got any ideas?

Chris Bray
LVL 3
chrisbrayAsked:
Who is Participating?
 
RomModConnect With a Mentor Commented:
The question has been PAQ'd and the 50 points have been refunded.
RomMod
Community Support Moderator
0
 
chrisbrayAuthor Commented:
The following solution appeared to work, but in fact caused problems with the data not being updated correctly:

type
   TwwDBGridCheat = class(TwwDBGrid);

procedure TForm1.Table1AfterInsert(DataSet: TDataSet);
begin
   with TwwDBGridCheat(wwDBGrid1) do
   begin
     SetActiveField('<The memo field>');

     CallMemoDialog();
   end;
end;

For whatever reason, the problem was that Table.Edit was not being called on
the table associated with the grid.  Why, I have been unable to find out.  I
have, however, been able to produce a workaround that gives even better
results ...

Basically I have created my own edit dialog with extended functionality
(Clear, Cut, Copy, Paste, and Print toolbar etc.), disabled the automatic
editor on the grid, and opened it programmatically:

procedure TTradePartnerForm.ShowMemoEditor;
begin
  MemoEditorDialog := TMemoEditorDialog.Create(Self);
  with MemoEditorDialog do
    begin
      NoteMemo.Text :=
      AccountNotesVDBTable.FieldByname('Note').AsString;
      case ShowModal of
        mrOK:
          begin
            if NoteMemo.Modified then
              begin
                AccountNotesvDBTable.Edit;
                AccountNotesVDBTable.FieldByName('Note').AsString :=
NoteMemo.Text;
                AccountNotesVDBTable.Post;
              end;
          end;
        mrCancel:
          begin
            AccountNotesVDBTable.Cancel;
          end;
      end;
      Release;
    end;
end;

This works correctly throughout, and can be called from the grid DblClick
event as well as the table OnNewRecord event or the edit button Click
event - or indeed anywhere else convenient.

Having answered my own question I intend to request that my points be refunded.

Chris Bray.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.