希望只输入整数数字,对于其他的输入不做响应。或者有没有其他的控件可完成这个功能?

解决方案 »

  1.   

    onkeypress里面判断一下就可以了
      

  2.   

    procedure TFrm1.edtKeyPress(Sender: TObject;
      var Key: Char);
    begin
      if not (Key in ['0'..'9', Char(VK_BACK), Char(VK_DELETE), Char(VK_RETURN)]) then
        Key := #0;
    end;
      

  3.   

    首先设置Form的keypreview属性为true;在onkeypress中写:if ((not(key in ['0'..'9'])) or (key<>#8)) then
    begin
      key := #0;
    end;
      

  4.   

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

  5.   

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