请问,怎么样才能让Delphi中的Edit控件在运行的时候只能输入integer类型或者string类型或者别的什么类型?
是在属性里面设置么?具体是哪个?

解决方案 »

  1.   

    可以考虑用TMaskEdit控件,也可以在TEdit的OnKeyPress事件中写代码
      

  2.   

    edit里面输入string类型肯定没有问题的,即使输进去0到9的数字也会被当作string类型处理的
    如果要限制输入的内容可以转化为integer类型的数据的话,可以在KeyPress等事件里面限制非0到9的按键操作就可以了
      

  3.   

    if key not in[0..9] then
      key=#0;
      

  4.   

    function CheckIntPass(AValue: string): boolean;
    begin
      Result := true;
      try
        StrToInt(AValue);
      except
        ShowMessage('请输入整数');
        Result := false;
      end;
    end;function CheckFloatPass(AValue: string): boolean;
    begin
      Result := true;
      try
        StrToFloat(AValue);
      except
        ShowMessage('请输入数值数据');
        Result := false;
      end;
    end;
      

  5.   

    在OnKeyPress事件里写,,,
    判断在你要的范围内。