有个Edit,我想当我输完号码后按回车执行查询操作
这样做行吗?procedure TForm5.Edit1Keydown(Sender: TObject;var Key: Word;  Shift: TShiftState);  可按了回车后没有反应

解决方案 »

  1.   

    if key=#13 then
    begin
    ...
    不知是否可以
      

  2.   

    在EDIT的OnKeyPress事件中写:if key=#13 then
    begin
      //你想执行的查询  ....
    end;
      

  3.   

    if key=13 then
    begin
    ...
    没有#
      

  4.   

    谢谢,是我写错了,我写的是这样:
    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;
      

  5.   

    可以单步执行,看是否进入了
    if (Key = #13) then
    begin
    end
    程序段中。如果有查询按钮,直接执行对应的click事件的函数,就省事多了。
    if (Key = #13) then
    begin
      btnQueryClick(nil); /
    end