当用户在dbgrid的计算字段输入两个小数点时,切换到下一个单元格就出错!这个必须怎么做呢?也就是说怎么限制在dbgrid的某个单元格只输入一个小数点!我在keypress限制为什么不行?
if dbgrid1.Columns[3].FieldName='字段'   then
if key in ['.'] then
  if Pos('.',dbgrid1.Columns[3].fieldname)>0 then
   Begin
    Key:=#0
   End;

解决方案 »

  1.   

    if dbgrid1.Columns[3].FieldName='字段'   then
    if key in ['.'] then
      if Pos('.',dbedit1.text(你的输入筐))>0 then
       Begin
        Key:=#0
       End;
      

  2.   

    if Pos('.',dbgrid1.Columns[3].fieldname)>0 then
    不是 FieldName 吧,应该是你输入的内容。
      

  3.   

    问题是我是在dbgrid输入的呀,这关dbedit什么事情呀!
      

  4.   

    你可以在需要检查的字段的OnSetText事件里这样写procedure TForm1.Table1FreightSetText(Sender: TField; const Text: String);
    begin
    try
       Table1.FieldByName('被检查的字段').AsFloat:=StrToFloat(Text);
    except
       showMessage('错误对话框');
       abort;
       end;
    end;