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.
^_^
^_^
解决方案 »
- 如何把颜色为32位的图像转成颜色为16位的图像
- 如何把RichEdit对齐方式做得象Word一样?!
- 数据库链接需要如何配置以下控件
- 我用osql.exe文件持行sql文件,但是不想让用户看到这些sql文件,我能否把这些sql文件放入dll文件内(能否持行),或者我把sql的脚本放入
- 一个简单问题,delphi7中为什么不能创建一个mts 对象?
- 特急~~怎么设置才能合Delphi不产生备份文件??
- 555~不活了!怎么对大学生也要求那么苛刻啊。
- 请介绍学习C/S结构的书!
- 请问如何在DBgrid中选中一行后使该行所有列变为同一颜色?在线等待!!!
- 求教AT命令,及让电脑发声
- 为什么我上午的问题现在看不了了 啊?
- 我想用delphi编写一个语音录制程序,但无从下手,请高手指点,怎样进行录制?
StringGrid1.Cols[0].insert是TStrings的一个成员函数,你在空字符串的第10个位置插如字符串,当然不行!
可以这样:
StringGrid1.Cols[0].strings[1] := 'zhang';当然还有其他方法
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;
直接插入好像不行,再优化一下吧。
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;