任何一控件(不要是stringgrid).SetFocus;
搞定!!
如果报错加一个时钟以延时!!

解决方案 »

  1.   

    我清空一个form上的stringgrid,然后formshow(self),可stringgrid上具有输入焦点的那一单元格的内容不能真正的清空,清空用的代码是:
     ………………
      ………………
    stringgrid.cells[i,j]:='';
      

  2.   

    我清空一个form上的stringgrid,然后formshow(self),可stringgrid上具有输入焦点的那一单元格的内容不能真正的清空,清空用的代码是:
     ………………
      ………………
    stringgrid.cells[i,j]:='';
      

  3.   

    stringgrid.col=其它列
    stringgrid.Row=其它行
      

  4.   

    to dgxum(明明) 
    不行,你的方法我试了,还是解决不了,那一单元格的内容还是不能清空
      

  5.   

    to : zygtp() 
     
    而且照你的方法去做了,还是不能清空那个单元格的内容
    麻烦大家试试好吗?
      

  6.   

    在stringgrid1的onclick事件中加入下面代码:
    procedure TForm1.StringGrid1Click(Sender: TObject);
    var
      row,col:Integer;
    begin
      row:=stringGrid1.row;
      col:=stringgrid1.col;
      if (row=2) and (col=3) then
       stringGrid1.Options:=stringGrid1.Options-[goEditing]
      else stringGrid1.Options:=stringGrid1.Options+[goEditing];
    end;
      

  7.   

    stringgrid.setfocus := false;
    for I := 0 to stringgrid.ColCount do
     for j:= 0 to stringgrid.rowcount do
    stringgrid.cells[i,j]:= ''
      

  8.   

    希望下面一段代码可以给你一点启发:
    procedure TForm1.BitBtn1Click(Sender: TObject);
    var
      myRect: TGridRect;
    begin
       if StringGrid1.Col<StringGrid1.ColCount-1 then
          begin
             myRect.Left := StringGrid1.col+1;
             myRect.Top := StringGrid1.row;
             myRect.Right := StringGrid1.col+1;
             myRect.Bottom := StringGrid1.Row;
          end
       else
          if StringGrid1.Row<StringGrid1.RowCount-1 then
             begin
                myRect.Left := 1;
                myRect.Top := StringGrid1.row+1;
                myRect.Right := 1;
                myRect.Bottom := StringGrid1.Row+1;
             end;
       if (StringGrid1.Row<StringGrid1.RowCount-1) or (StringGrid1.Col<StringGrid1.ColCount-1) then
          begin
             StringGrid1.Selection := myRect;
             Application.MessageBox(PCHAR('当前行:'+IntToStr(StringGrid1.Row)+'当前列:'+IntToStr(StringGrid1.Col)),'提示',MB_OK);
          end;
    end;
      

  9.   

    应该是
    stringgrid.setfocus := false;
    for I := 0 to stringgrid.ColCount-1 do
     for j:= 0 to stringgrid.rowcount-1 do
      stringgrid.cells[i,j]:= ''
      

  10.   

    procedure TForm1.StringGridClick(Sender: TObject);
    var i,j:integer;
    begin
    for I := 0 to stringgrid.ColCount do
     for j:= 0 to stringgrid.rowcount do
    stringgrid.cells[i,j]:= ''
    end;
      

  11.   

    上一个是单击stringgrid
    这个是用一个按钮来。
    procedure TForm1.BitBtn1Click(Sender: TObject);
    var i,j:integer;
    begin
    //stringgrid.setfocus := false;
    for I := 0 to stringgrid.ColCount do
     for j:= 0 to stringgrid.rowcount do
    stringgrid.cells[i,j]:= ''
    end;
      

  12.   

    谢谢给位了
    问题已经解决
    是zhuoyuesky(卓越) 兄给了我启示,我在selectcell事件中有公共变量没释放,不过还是要谢谢大家
    都有分的!!