提供一点可行性代码:以下代码在STUDIO中运行是可以的,但在正式运行起来后就不起作用,WHY?
procedure TCONTACTFORM.BizFormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
lFieldName: string;
begin
Inherited;
if Key = Borland.Delphi.Windows.VK_RETURN then // .VK_F2
begin
if ActiveControl.Parent is Business.Forms.TBaseEdit then
begin
lFieldName := TBaseEdit(ActiveControl.Parent).DataField;
lFieldName := SysUtils.UpperCase(lFieldName);
end;
if lFieldName = 'CONTACTPERSON' then //联系人回车 焦点自动跳到 联系电话
RefDoc.RefInfo.sdsDataSet.FieldByName('CONTACTPHONE').FocusControl
else if lFieldName = 'CONTACTPHONE' then //联系电话回车 焦点自动跳到 联系部门
RefDoc.RefInfo.sdsDataSet.FieldByName('CONTACTDEPT').FocusControl;
Tprogram.ShowMsg(lFieldName);
//其它控件...
Key := 0; //可解决两次触发的问题
end;