我正在尝试在 Delphi XE2 Firemonkey 中从文件中加载 stringgrid。当我在 Delphi 中这样做时,它看起来像这样:
procedure TForm1.File2StringGrid(Sender: TObject);
var
F: TextFile;
Tmp, x, y: Integer;
TmpStr: string;
begin
AssignFile(F, (ExtractFilePath(ParamStr(0))+'stringgrid1.sgf'));
Reset(F);
Readln(F, Tmp);
StringGrid1.ColumnCount:=Tmp;
Readln(F, Tmp);
StringGrid1.RowCount:=Tmp;
for x:=0 to StringGrid1.ColumnCount-1 do
for y:=0 to StringGrid1.RowCount-1 do
begin
Readln(F, TmpStr);
StringGrid1.Cells[x,y]:=TmpStr;
end;
CloseFile(F);
end;
在 Firemonkey 中出错:[DCC Error] Unit1.pas(179): E2129 Cannot assign to a read-only property in line: StringGrid1.ColumnCount:=Tmp;
任何想法如何解决它?