在ondrawcell里作判断吧
例如:
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
  if TStringGrid(Sender).cells[ACol,ARow]<>'' then TStringGrid(Sender).cells[ACol,ARow]:='';
  inherited;
end;

解决方案 »

  1.   

    用TopGrid控件吧。在www.51delphi.com中有。一定能达到你的要求。
      

  2.   

    如果非用STRINGGRID不可,那就在onkeypress和onkeydown事件中编程判断吧.
      

  3.   

    如果非得用STRINGGRID,那就在onkeypress和onkeydown事件中编程控制吧.
      

  4.   

    procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
    begin
      if (stringgrid1.col=1) and not (key in ['0'..'9']) then
        key:=char(0);
    end;
      

  5.   

    在onkeypress事件里写如下代码,可以使用退格键。
    procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
    begin
      if not (key in ['0'..'9',#8]) then
        key := #0;
    end;
      

  6.   

    ondrawcell event var
      DrawString:string;
      Sw,Sh,x,y:integer;
    begin
      DrawString:=Sg_TurnOver.Cells[acol,arow];
      Sg_TurnOver.Canvas.FillRect(Rect);
      Sw:=Sg_TurnOver.Canvas.TextWidth(DrawString);
      Sh:=Sg_TurnOver.Canvas.TextHeight(DrawString);
      if (Acol=1) and (Arow >0) then
      begin
        if drawstring='' then
          Exit;
      DrawString:=Formatcurr('#,##0.00',StrToCurr(Sg_TurnOver.Cells[ACol,ARow]));
      Sg_TurnOver.Canvas.FillRect(Rect);
      Sw:=Sg_TurnOver.Canvas.TextWidth(DrawString);
      Sh:=Sg_TurnOver.Canvas.TextHeight(DrawString);
        if (Sw > (rect.Right - rect.left)) then
        begin
           x:=4;
           y:=(rect.Bottom - rect.top - Sh) div 2;
           Sg_TurnOver.Canvas.TextOut(rect.left + x ,rect.top + y,Sg_TurnOver.Cells[ACol,ARow]);
         end
         else
         begin
           x:=(rect.Right - rect.left - sw) div 2;
           y:= (rect.Bottom - rect.top - sh) div 2;
           Sg_TurnOver.Canvas.TextOut(rect.right-sw-6,rect.top + y,Formatcurr('#,##0.00',StrToCurr(Sg_TurnOver.Cells[ACol,ARow])));     end;
      end
      else
      begin
        if (Sw > (rect.Right - rect.left)) then //只能左对齐
        begin
          x:=4;
          y:=(rect.Bottom - rect.top - Sh) div 2;
          Sg_TurnOver.Canvas.TextOut(rect.left + x ,rect.top + y,Sg_TurnOver.Cells[ACol,ARow]);
        end
        else
        begin
          x:=(rect.Right - rect.left - sw) div 2;
          y:= (rect.Bottom - rect.top - sh) div 2;
          Sg_TurnOver.Canvas.TextOut(rect.left + x ,rect.top + y,Sg_TurnOver.Cells[ACol,ARow]);
        end;
      end;
    OnSelectCell中begin
      if (Sg_TurnOver.Cells[acol,arow]='0') or (Sg_TurnOver.Cells[acol,arow]='') then
        exit;
      try
        EndPrice := StrToCurr(Sg_TurnOver.Cells[acol,arow]);
      except
        MessageDlg('此栏['+Sg_TurnOver.Cells[0,Arow]+','+Sg_TurnOver.Cells[Acol,0]+']金额输入错误!',mtError,[mbOK],0);
        exit;
      end;
    end;
      

  7.   

    我倒是觉得应该在OnSetEditText事件判断
      

  8.   

    可以用onkeypress来完成你要的功能,代码就如  feng6060_cn()兄所写,
    还要在form中设置一个属性:keypreview 为True
      

  9.   

    在stringGrid的onkeypress事件里写如下代码:
      if not (key in ['0'..'9',#13,#8]) then  //#13回车;#8退格
        key := chr(0);
      

  10.   

    tiga 的我编译过了,可行的
    你试看吧