循环生成的内容在下次再生成之前内容没有清空的话,第二次生成的循环如果有某个cell是空的话就会出现第一次的内容。有没有解决的方法?

解决方案 »

  1.   

    2个办法。1.在填写内容的时候,把即使不填写的cell也写一个''来覆盖。
    2.写一个过程来完成对StringGrid的清理工作,
      

  2.   

    var
    sRow: Integer;
    begin
    for sRow:= StringGrid.RowCount downto 0 do
       N_Grid.Rows[sRow].Clear;
    end;
      

  3.   

    with stringgrid1 do
    begin//初始化
      rowcount:=2;
    rows[1].clear;
    end;
    //循环添加数据
    with stringgrid1 do
    begin
    while not eof do
    begin
      cells[0,rowcount-1]:=;
      ...
    rowcount:=rowcount+1;
    rows[rowcount-1].clear;
    next;
    end;
    end;
      

  4.   

    ScoutKing(失眠夜) 写的挺好,
    StringGrid的cols和Rows都是TStrings,直接调用他的Clear方法效率比 一个一个的清空Cell高得多。
    不过他有个错误,就是Rows的范围是从RowCount-1到0的,不是从RowCount到0。var
      sRow: Integer;
    begin
      for sRow:= StringGrid.RowCount-1 downto 0 do
        N_Grid.Rows[sRow].Clear;
    end;
      

  5.   

    for i := 0 to AStringGrid.RowCount - 1 do
      AStringGrid.Rows[i].Clear;