文本框只能输入数字,可是,使用搜狗输入法打了一连串字符,按回车就会判断好多次

解决方案 »

  1.   

    procedure TIQPC_CY_F.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin 
      if not (key  in['0'..'9',#13,#8]) then key:=#13;
    end;
      

  2.   

    function TDP_KPAPRTRULE_Detail_f.CheckEdit(const Value: string): Boolean;
    var
        p: pChar;
    begin
        result := false;
        p := pChar(Value);    while p^ <> #0 do
        begin
            if not (p^ in [#8, '0'..'9', 'A'..'Z', '-', '*']) then exit;
            inc(p);
        end;    result := true;
    end;在OnChange事件中调这个方法
      

  3.   

    在 onKeyPress事件中if not(Key in ['0'..'9',#8]) then Key := #0;
      

  4.   

    onkeypress
      if not((key in ['0'..'9',#8]) ) then
           key := #0;
      

  5.   

    onkeypress : 
    if not((key in ['0'..'9',#8]) ) then 
          key := #0;