如何实现同一FORM上的多个EDIT 输入内容不同(数字),如何规定每个EDIT中输入数的最大限制 ,如最大输入只能是36 

解决方案 »

  1.   

    if Edit1.Text.Length() >= 36 then
      Key = nil
      

  2.   

    在OnKeyPress里面判断:
    try
      if strtoint(Edit1.Text)>=36 then Key := $0
    except
    end
      

  3.   

    在form.show里
    edit1.maxlength:=36;
      

  4.   


    在OnKeyPress里面判断:
    try
      if StrToInt(Edit1.Text) > 36 || StrToInt(Edit1.Text) < 1 then
         Key = nil
    except
        Key = nil;   //不是数字
    end
      

  5.   

    改一下
    在OnKeyPress里面判断:
    try
      if StrToInt(Edit1.Text+Key) > 36 || StrToInt(Edit1.Text+Key) < 1 then
         Key = nil
    except
        Key = nil;   //不是数字
    end
      

  6.   

    在edit的ONchange事件中﹕
    try
      if StrToInt(Edit1.Text) > 36 then
         edit1.text:='36';
    except
        edit1.text:='0';   //不是数字
    end
      

  7.   

    ||是c里的,在delphi里也可以吗?
      

  8.   

    我明白你的意思了,像你这种情况只能是写一个继承TEdit的控件来实现你的需求了。
    这很简单的。
      

  9.   

    Edit控件中的MaxLength属性,就可以指定最大输入数。
      

  10.   

    试了一下;
    1.procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
    try
     if length(Edit1.Text)>=5 then
      Key := #0;
    except
    ShowMessage('not');
    end;
    end;2.procedure TForm1.FormCreate(Sender: TObject);
    begin
      Edit1.MaxLength := 5;
    end;各位都在上面说过了的....
      

  11.   

    在edit的ONKeyPress事件中﹕
    if not (Key in['0'..'9',#8,#13]) then key=#0
    else if StrToInt(Edit1.Text) > 36 then
       begin     
       edit1.text:='36';
       showmessage('输入最大值为36')
       end;