[SOLVED] Any way to restrict new record being inserted by down key on DBGrid? lazarus / 16-Databases ---------------------------------------------------------------------- egsuh · 2025-10-15 07:44 Currently a new record is inserted automatically when I press down key at the bottom of DBGrid. I'd like a new record is not inserted by pressing down key. And insert is done only by pressing (+) button of DBNavigator. Is there any way to do this? ---------------------------------------------------------------------- Zvoni · 2025-10-15 08:00 hmmm.... untested: Use a blocking variable (Form-Wide boolean?) which is permanently false, and only gets set to True, when clicking on "+". Then you might be able to use the OnBeforeInsert-Event of the underlying TDataset, there checking if the Blocker is True or False True = User clicked the "+" --> Proceed with inserting False = User navigated in the Grid --> "abort" (Hint) But as i said: untested EDIT: I seem to remember there being an option for DBGrid, but for the life of me i can't remember/find it ---------------------------------------------------------------------- cdbc · 2025-10-15 08:28 Hi Maybe intercept the key in a GridKeyDown-Handler and the set the key to 0 Regards Benny ---------------------------------------------------------------------- LacaK · 2025-10-15 08:52 Can you try to set in TDBGrid.Options dgDisableInsert ? ---------------------------------------------------------------------- Zvoni · 2025-10-15 09:13 Quote from: cdbc on October 15, 2025, 10:28:15 amHi Maybe intercept the key in a GridKeyDown-Handler and the set the key to 0 Regards Benny That would prevent navigating the Grid, no? ---------------------------------------------------------------------- Zvoni · 2025-10-15 09:18 Quote from: LacaK on October 15, 2025, 10:52:44 amCan you try to set in TDBGrid.Options dgDisableInsert ? Yepp, looks like that's the option i was alluding to. Just tested it with a Project i'm currently working on, which has a DBGrid with a DBNavigator. set the option, moving with arrow down doesn't add a new row, but clicking on "+" inserts a new row at cursor location. Now for my own project i only have to find out, how to force the new inserted row to always appear at the bottom of the Grid, irrespective where the cursor was when user clicked on "+" EDIT: Which alludes to "append" instead of "Insert". Ah well, off i go hunting..... ---------------------------------------------------------------------- egsuh · 2025-10-16 08:18 QuoteCan you try to set in TDBGrid.Options dgDisableInsert ? Yes, this does what  I want to do. Thanks a lot. Waiting Zboni to find some way to "append" record ^^ ---------------------------------------------------------------------- Zvoni · 2025-10-16 09:55 Quote from: egsuh on October 16, 2025, 10:18:03 amQuoteCan you try to set in TDBGrid.Options dgDisableInsert ? Yes, this does what  I want to do. Thanks a lot. Waiting Zboni to find some way to "append" record ^^ Found it: --> https://forum.lazarus.freepascal.org/index.php?topic=25438.0 Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TFormPowerUser.dbnPowerUsersClick(Sender: TObject;  Button: TDBNavButtonType);Var m:String;begin  Case Button Of    nbInsert: Begin                IsDirty:=True;                (Sender as TDBNavigator).DataSource.DataSet.Append;  //THIS ONE              End;    //nbInsert,    nbEdit,    nbDelete: IsDirty:=True;    nbPost  : Begin                SaveChanges;                IsDirty:=False;            end;    nbCancel: Begin                DiscardChanges;              IsDirty:=False;              end;  end;end;