1.设Form的Preview 为True,设Edit1,Edit2...EditN 的TabOrder分别为0,1...n-12. 在form的KeyPresss中添加下列代码 if key=#13 then begin Key := #0; SelectNext(ActiveControl,True); end;
先设置 self.keyPreview:=True;Procedure TForm1.FormKeyPress(Sender:Tobject;Var Key:Char); Begin if key=#13 then Begin key:=#0; Perform(WM_NEXTDLGCTL,0,0); end end;
dbedit2.setfocus;
begin
Key := #0;
SelectNext(ActiveControl,True);
end;
Begin
if key=#13 then
Begin
key:=#0;
Perform(WM_NEXTDLGCTL,0,0);
end
end;
在onkeypress中:
if key=#13 then
PostMessage(Handle, WM_NEXTDLGCTL, 0 ,0);
if key=vk_return then
edit2.setfocus;