I have a small button that I want to add to the upper left corner of the Delphi TDBGrid component (in the header / header cells). I can easily place the button, but now the click event is not being processed. I assume the event is caught in a grid. Anyway, can I get this particular event to go to the button? Note. I still need a grid to handle click events for its header buttons, as is currently the case.
procedure TForm38.FormCreate(Sender: TObject);
begin
button1.Parent := grid;
button1.Top := 0;
button1.Left := 0;
button1.Width := 12;
button1.Height := 18;
button1.OnClick := Button1Click;
end;
** Update: ** I found that I was able to use the MouseDown button, which seems to work well, but I could not use the click event.
procedure TForm38.Button1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if ( Button = mbLeft ) then
TButton(Sender).Click;
end;
source
share