1

did when pressing button select all the lines in dbgrid, can I select all the lines when ctrl + a is pressed?

function GridSelectAll(Grid: TDBGrid): Longint;
begin
  Result := 0;
  Grid.SelectedRows.Clear;
  with Grid.Datasource.DataSet do
  begin
    First;
    DisableControls;
    try
      while not EOF do
      begin
        Grid.SelectedRows.CurrentRowSelected := True;
        inc(Result);
        Next;
      end;
    finally
      EnableControls;
    end;
  end;
end;

procedure TForm2.btn13Click(Sender: TObject);
begin
  GridSelectAll(dbgrd1);
end;
ariana
  • 33
  • 7

1 Answers1

0
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin   if (ssCtrl in Shift) and (Key = $41) then
    then  GridSelectAll(dbgrd1); end;
delphi
  • 166
  • 9
  • hi, answers are always much better when there is somewhat explanation in them. Your code might work, but you dont explain why or what you are doing. – GuidoG Mar 09 '18 at 16:38