首先設置Form1的KeyPreview屬性為True.<br>procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);<br>begin<br> if Key=#13 then<br> Begin<br> If Not (ActiveControl is TDbgrid) Then<br> perform(WM_NEXTDLGCTL,0,0);<br> Else<br> SendMessage(TDbgrid(ActiveControl).handle,WM_KEYDOWN,VK_TAB,0);<br> key:=#0;<br><br> End;<br>end;