在EDIT的OnKeyPress事件中写:if key=#13 then begin //你想执行的查询 .... end;
if key=13 then begin ... 没有#
谢谢,是我写错了,我写的是这样: procedure TForm5.suiEdit1KeyPress(Sender: TObject;var Key: Char); begin if (Key = #13) then begin with Oraquery1 do begin SQL.Clear; SQL.add('select (a.serv_name,a.id_card,b.detail,a.serv_type_id,a.cust_type_id,a.billing_type_id,a.vip_flag,a.urge_flag,a.country_flag)from serv a,address b where a.address_id=b.address_id and a.state=''F0A'' and a.acc_nbr =:acc_nbr'); if oraquery1.Prepared=false then prepare; paramByName('acc_nbr').AsString:=trim(suiEdit1.text); showmessage(oraquery1.SQL.Text); open;
可以单步执行,看是否进入了 if (Key = #13) then begin end 程序段中。如果有查询按钮,直接执行对应的click事件的函数,就省事多了。 if (Key = #13) then begin btnQueryClick(nil); / end
begin
...
不知是否可以
begin
//你想执行的查询 ....
end;
begin
...
没有#
procedure TForm5.suiEdit1KeyPress(Sender: TObject;var Key: Char);
begin
if (Key = #13) then
begin
with Oraquery1 do
begin
SQL.Clear;
SQL.add('select (a.serv_name,a.id_card,b.detail,a.serv_type_id,a.cust_type_id,a.billing_type_id,a.vip_flag,a.urge_flag,a.country_flag)from serv a,address b where a.address_id=b.address_id and a.state=''F0A'' and a.acc_nbr =:acc_nbr');
if oraquery1.Prepared=false then
prepare;
paramByName('acc_nbr').AsString:=trim(suiEdit1.text);
showmessage(oraquery1.SQL.Text);
open;
if (Key = #13) then
begin
end
程序段中。如果有查询按钮,直接执行对应的click事件的函数,就省事多了。
if (Key = #13) then
begin
btnQueryClick(nil); /
end