怎么能让ComboBox只能输入数字,数值(包括加,减,小数点)  过滤KeyDown,Up,Keypress事件都没有用??

解决方案 »

  1.   

    procedure TForm1.Edit1KeyPress(Sender: TObject; var Key: Char);
    begin
         if  not (key  in ['0'..'9',#8,'.']) then
         begin
         MessageBox(Form1.Handle,'请输入数字','错误',MB_OK or MB_ICONINFORMATION);
         key:=#0;
         end;
    end;这个和你说的应该差不多吧
      

  2.   

    在ComboBox的onkeypress事件中插入代码:if not ((order(key) >= 48 and order(key) <= 57) or order(key) = 45 or order(key) = 46 or order(key) = 43) then
    begin
      key := #0;
    end;
      

  3.   

    if not (Key in ['0'..'9',#8,#43,#45,#46]) then
        Key := #0;在ComboBox的Keypress事件输入那段代码就可以了 我刚测试过的~~