• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 261
  • Last Modified:

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
0
chrisbray
Asked:
chrisbray
1 Solution
 
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
 
RomModCommented:
The question has been PAQ'd and the 50 points have been refunded.
RomMod
Community Support Moderator
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now