procedure Insert(Index: Integer; const S: string); override;DescriptionBecause TStringGridStrings objects represent the rows or columns of a string grid, the number of entries in the list must correspond exactly to the number of cells in the corresponding row or column. Rather than allow entries to be inserted, destroying this correspondence, Insert raises an EInvalidGridOperation exception.
^_^

解决方案 »

  1.   

    有逻辑错误StringGrid1.Cols[0]是一个TStrings类型
    StringGrid1.Cols[0].insert是TStrings的一个成员函数,你在空字符串的第10个位置插如字符串,当然不行!
    可以这样:
       StringGrid1.Cols[0].strings[1] := 'zhang';当然还有其他方法
      

  2.   

    var i:integer;
        st:TStringList;
    begin
      st := TStringlist.Create;
      st.Insert(0,'dddd3');
      StringGrid1.RowCount := StringGrid1.RowCount +1;
      for i:=0 to StringGrid1.ColCount -1 do
      begin
        st.Text := StringGrid1.Rows[StringGrid1.Row].Text;
        st.Insert(StringGrid1.col,'zhang');
        StringGrid1.Rows[StringGrid1.Row].Text := st.Text;
      end;
      st.free;
    直接插入好像不行,再优化一下吧。
      

  3.   

    对不起,刚才写错了。var i:integer;
        st:TStringList;
    begin
      st := TStringlist.Create;
      try
        StringGrid1.RowCount := StringGrid1.RowCount +1;
        for i:=0 to StringGrid1.ColCount -1 do
        begin
          st.Text := StringGrid1.Cols[i].Text;
          st.Insert(StringGrid1.Row,Edit1.Text);
          StringGrid1.Cols[i].Text := st.Text;
        end;
        StringGrid1.Row := StringGrid1.Row + 1;
      finally
        st.free;
      end;