procedure EditKEYPRESS(Frm: TForm; Sender: TObject; var Key: Char);var Edit1, Edit2: TEdit; i, k : integer;begin if key<>#13 then exit; Edit1:=@Sender; 这里处理判断是第几个Edit,记下来 for i:=0 to Edit1.Owner.ComponentCount-1 do begin if Edit1.Owner.Components.ClassName='TEdit' then begin Edit2:=TEdit(Edit1.Owner.Components); 如果是需要获得焦点的edit end; end;end;创建Edit的地方:var KEYPRESSEvent : TNotifyEvent;begin Edit := TEdit.Create(Form); with Edit do begin Name:='Edit1'; Parent := Panel; Left := 46; Width:=280; Top := 6; Text := ''; end; KEYPRESSEvent :=nil; integer(@KEYPRESSEvent) := integer(@EditKEYPRESS); Edit.KEYPRESS:=KEYPRESSEvent;