SuperMMX:用以下代码试试,我给出了两种方法,一种用DBEdit,另一种用EDit,好象用DBEDit比较方便,在我的机上试验成功.
procedure TForm1.MyEditKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
Var FieldName:string;
i:integer;
begin
if Key = VK_F3 then
begin
//如果使用DbEdit可以使用datafield属性得到fieldName
FieldName:=(Sender as TDBEdit).DataField;
Application.MessageBox(PCHar(FieldName),'Uses TDBEdit The Field is',MB_OK);
for i:=0 to MyEditList.Count-1 do
begin
//使用Edit要先判断焦点在那一个Edit上
if Pointer(form1.ActiveControl)=MyEditList.Items Then
begin
FieldName:=Table1.Fields.FieldName;
Application.MessageBox(PCHar(FieldName),'Uses Edit The Field is',MB_OK);
Break;
end;
end;
end;
end;