我做了一段过程你可以试一试
procedure Tftyhsgc.ENTERTOTAB(SenderCS: TObject; DQCK: TFORM; var KEYCS: WORD; ShiftCS: TShiftState);
//模拟回车为TAB键
//DQCK 当前窗口 KEYCS 虚拟键值
var
XNKEY: WORD;
begin
XNKEY := KEYCS;
if (KEYCS = vk_return) then
if not (DQCK.ActiveControl is TDbgrid) and not (DQCK.ActiveControl is TwwDbgrid) then
DQCK.perform(cm_dialogkey, vk_DOWN, 0)
else
if (DQCK.ActiveControl is TDbgrid) and not (DQCK.ActiveControl is TwwDbgrid) then {是在 TDbgrid 控件内}
begin
with TDbgrid(DQCK.ActiveControl) do
if Selectedindex < (FieldCount - 1) then
Selectedindex := Selectedindex + 1 { 移动到下一字段}
else
Selectedindex := 0;
end;
if (keyCS = vk_down) then
if not (DQCK.ActiveControl is TDbgrid)
and not (DQCK.ActiveControl is TwwDbgrid)
and not (DQCK.ActiveControl is Twwpopupgrid)
and not (DQCK.ActiveControl is TwwDblookupcombo)
and not (DQCK.ActiveControl is TwwDbcombobox)
then
DQCK.perform(cm_dialogkey, vk_DOWN, 0);
if keyCS = vk_up then
if not (DQCK.ActiveControl is TDbgrid)
and not (DQCK.ActiveControl is TwwDbgrid)
and not (DQCK.ActiveControl is Twwpopupgrid)
and not (DQCK.ActiveControl is TwwDblookupcombo)
and not (DQCK.ActiveControl is TwwDbcombobox)
then
DQCK.perform(cm_dialogkey, vk_UP, 0);
end;