Jump to content


Photo

DBGrid add/del rows with Ins/DEL keys

dbgrid insert rows delete

  • Please log in to reply
1 reply to this topic

#1 csanesz

csanesz
  • Members
  • 2 posts

Posted 21 January 2022 - 02:45 PM

Hi,

 

In the NextDBGrid v4.4.5

--- added: doInsDelKeys flag in DataAwareOptions property. When True, Ins key will Insert new record (DataSet.Insert). Delete key deletes record (DataSet.Delete)

 

But in 6.6.0 version this options is not found.

 

In 4.4.5 this source code:

  1. procedure TNextDBGrid.KeyDown(var Key: Word; Shift: TShiftState);
  2. var
  3.   AcceptDelete: Boolean;
  4. begin
  5.   { Support for Insert and Delete keys }
  6.   if (doInsDelKeys in FDataAwareOptions)
  7.     and IsDataSetActive
  8.     and not FDataLink.ReadOnly
  9.     and not(gtEdit in GridState) then
  10.   begin
  11.     case Key of
  12.       VK_INSERT: FDataLink.DataSet.Insert;
  13.       VK_DELETE:
  14.         begin
  15.           if not FDataLink.DataSet.IsEmpty then
  16.             begin
  17.               AcceptDelete := True;
  18.               DoDeleteRecord(AcceptDelete);
  19.               if AcceptDelete then FDataLink.DataSet.Delete;
  20.            end;
  21.         end;
  22.         VK_ESCAPE: FDataLink.DataSet.Cancel;
  23.     end;
  24.   end;
  25.   if not(doBufferRecords in DataAwareOptions) then  
  26.     begin
  27.       case Key of
  28.         VK_PRIOR: SendMessage(Handle, WM_VSCROLL, SB_PAGEUP, 0);
  29.         VK_NEXT: SendMessage(Handle, WM_VSCROLL, SB_PAGEDOWN, 0);
  30.         VK_HOME: SendMessage(Handle, WM_VSCROLL, SB_TOP, 0);
  31.         VK_END: SendMessage(Handle, WM_VSCROLL, SB_BOTTOM, 0);
  32.       else inherited KeyDown(Key, Shift);
  33.     end;
  34.   end else inherited KeyDown(Key, Shift);
  35. end;

Can i have INS and DEL keys the new records/delete records?.

In this version not found KeyDown method.

 

Thanks!



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,220 posts
  • Gender:Male

Posted 22 January 2022 - 12:37 AM

Hello,

 

Sure, I will add it again. Hope for the next release.


boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users