研究研究这个例子 DBGrid1KeyPress(Sender: TObject; var Key: Char) begin if Key = #13 then //回车键 begin if not (ActiveControl is TDBGrid) then begin Key := #0; // eat enter key Perform(WM_NEXTDLGCTL, 0, 0); // move to next control end else if (ActiveControl is TDBGrid) then // if it is a TDBGrid with TDBGrid(ActiveControl) do if selectedindex < (fieldcount -1) then // increment the field selectedindex := selectedindex +1 else selectedindex := 0; end; end;
DBGrid1KeyPress(Sender: TObject; var Key: Char)
begin
if Key = #13 then //回车键
begin
if not (ActiveControl is TDBGrid) then
begin
Key := #0; // eat enter key
Perform(WM_NEXTDLGCTL, 0, 0); // move to next control
end
else if (ActiveControl is TDBGrid) then // if it is a TDBGrid
with TDBGrid(ActiveControl) do
if selectedindex < (fieldcount -1) then // increment the field
selectedindex := selectedindex +1
else
selectedindex := 0;
end;
end;