Link to home
Start Free TrialLog in
Avatar of boardtc
boardtcFlag for Ireland

asked on

Intercepting INS in TDbGrid

Hi, I have an OnVlick event on by TDBNavigator that gets executes when the user clicks on the Insert button. I want the same code executed when the user hits ins in the TDBGRid. How can I intercept this?

Thank you,

Tom.
Avatar of kretzschmar
kretzschmar
Flag of Germany image

hi tom,

you can use the dbgrid.onkeydown or keyup-event like

procedure TForm1.dbgrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key = vk_Insert then
    showmessage('Insert');  //here should be your code
end;

or you can trigger the beforeinsert-event of your dataset
(this happens allways (key and nav-button))

meikl
Avatar of boardtc

ASKER

Meikl, my thinking cap wasn't on, thank you, please answer to grade. Tom.
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of boardtc

ASKER

ha ha :-)