先将窗体的KeyPreview属性设为True。然后在FormKeyPress事件中加入以下代码:
procedure TF_openaccount.FormKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
selectnext(activecontrol as twincontrol,true,true);
key:=#0;
end;
end;
帮助信息:
VCL Reference
SelectNext method (TWinControl)
TWinControl See also
Moves the input focus from the current child control to the next one in the tab order.
Delphi syntax:
procedure SelectNext(CurControl: TWinControl; GoForward, CheckTabStop: Boolean);
C++ syntax:
void __fastcall SelectNext(TWinControl* CurControl, bool GoForward, bool CheckTabStop);
Description
Call SelectNext to move the child control focus. SelectNext selects the first child that follows or precedes CurControl in the tab order and that meets the criteria specified in the other parameters.
The GoForward parameter controls the direction of the search. If GoForward is true, FindNextControl searches forward through the child controls in tab order. If GoForward is false, SelectNext searches backward through the controls. The search wraps past the end of the collection back to CurControl.
The CheckTabStop parameter controls whether the control SelectNext finds must be a tab stop. If CheckTabStop is true, the returned control must have its TabStop property set to true, or the search for the next control continues.
If a child control matches the search criteria, that control obtains the focus. If no such child control is found, the focus remains unchanged.