procedure TfrmCB.F1Book1KeyPress(Sender: TObject; var Key: Char);
begin
  if not (Key in ['0'..'9','.',#8]) then 
    Key:=#0;
end;
当输入"3DF"时,拦不下"DF"这两个字母

解决方案 »

  1.   

    这样来判断:
    procedure TForm1.F1Book61EndEdit(Sender: TObject;
      var EditString: WideString; var Cancel: Smallint);
    begin
      try
        strtofloat(EditString)
      except
        showmessage('不是一个有效的数值');
        cancel:=1;
      end;
    end;
      

  2.   

    Var
      CellFmt: F1CellFormat; 
    begin
      CellFmt :=Formulabook1.CreateNewCellFormat;
      Cellfmt.NumberFormat[1]:='#,###.##;(#,###.##);0;"Error: Entry mustbe numeric"';//'#,###';
      F1book1.SetCellFormat(CellFmt);