是否在Form的keypress事件中有key := #0;语句啊
formkeypress先于edit1keypress执行

解决方案 »

  1.   

    onkeypress 不能處理非字符鍵.........onkeydown 都可以
      

  2.   

    因为formkeypress先于edit1keypress执行 ,你在keypress中将回车键屏蔽掉了
      

  3.   

    hlihna:你的意思是,我在eidt1keypress将回车给屏蔽掉了吗?
      

  4.   

    给Edit发消息就可以了
    PostMessage(edit1.handle.WM_KEYGOWN,VK_TAB,0);
      

  5.   

    to:zfpcb(我是你的传说) 
    但是我有很多的edit呀!
    to:hlilna()
    我在edit.onkeypress中:
    if not (key in ['0'..'9','.',#8,#13]) then
    begin
      key := #0;
      showmessage('请您勿必输入0-9之间的数字!');
    end;在formkeypress中:
    if key=#13 then
      perform(WM_NEXTDLGCTL,0,0);
    为什么不行呀
      

  6.   

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
    if Edit1.Text<>'' then
    begin
      if key = #13 then
      begin
        Keybd_event(VK_TAB,MapVirtualKey(VK_TAB,0),0,0);
        Keybd_event(VK_TAB,MapVirtualKey(VK_TAB,0),KEYEVENTF_KEYUP,0);
      end;
    end
    else begin
    if not (key in ['0'..'9','.',#8]) then
    begin
      key := #0;
      showmessage('请您勿必输入0-9之间的数字!');
    end;
    end;
    end;
    这样就不要处理FORM的KEYPRESS事件了,给分、
      

  7.   

    还是不行呀,你试过了吗?
    主要是我在点确定按钮的时候还要判断是不是空!
    if Trim(Ed_pro_id.Text) = '' then
     if application.MessageBox ('请填写产品序号!','提示',MB_OK) = IDOK then
       begin
       Ed_pro_id.SetFocus ;
       exit;
       end;
    这样的话,敲回车,就显示了下一个edit的message了,为什么?
    有什么方法吗?
      

  8.   

    procedure TForm1.Ed_pro_idExit(Sender: TObject);
    begin
      if Trim(TEdit(Sender).Text) = '' then
        if Application.MessageBox ('请填写产品序号!','提示',MB_OK) = IDOK then begin
          TEdit(Sender).SetFocus ;
          Exit;
        end;
    end;
      

  9.   


    procedure TForm1.Edit3KeyPress(Sender: TObject; var Key: Char);
    begin
      if not (key in ['0','1','2','3','4','5','6','7','8','9']) then
      begin
         showmessage('');  
         Abort;
      end ;
    end;procedure TForm1.Edit3KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    begin
      if comparestr(Edit3.Text,'')=0 then
      Abort;
      if Key = 13 then
      begin
        Edit4.SetFocus;
      end;
    end;
    我试过了,不知能否合你的要求
      

  10.   

    还是不行呀,我一敲回车,他还是直接响应到我的button了
      

  11.   


    press是在某一东东上发生了down then up
    down & up则是分开。