我想控制输入到edit、memo等控件里的内容,可以控制它输入的类型,如数字、或字符,在线等待

解决方案 »

  1.   

    在edit、memo的OnKeyPress事件里面进行控制。
      

  2.   

    只能输入数字,小数点的方法:
    if not (key in ['0'..'9','.',#8]) then key := #0;#8 为退格键(Backspace)
      

  3.   

    if not (key in ['0'..'9',#8]) then key := #0; 数字 0-9if not (key in ['A'..'Z',#8]) then key := #0; 大写字母if not (key in ['a'..'z',#8]) then key := #0; 小写字母
      

  4.   

    if not (Key in ['0'..'9','.',#8,#13]) then
        Key:=#0;
        if Key='.' then
        begin
            if (Pos('.',TEdit(Sender).Text)<>0)or(Length(TEdit(Sender).Text)=TEdit(Sender).SelLength)
                or(TEdit(Sender).SelStart=0) then
            Key:=#0;
        end;這是只允許輸入數字和小數點的一段代碼﹐小數點只允許輸入1個﹐還不允許在第一位輸入
    在OnExit判斷是否全理就行