procedure TForm1.Button1Click(Sender: TObject);
Var
F: TextFile;
i,j: Integer;
begin
AssignFile(F, 'C:\1.txt');
Rewrite(F);
For i:= 0 To StringGrid1.ColCount - 1 Do
For j:= 0 To StringGrid1.RowCount - 1 Do
Writeln(F, StringGrid1.Cells[i,j]);
CloseFile(F);
end;
Чтение:
Код:
procedure TForm1.Button2Click(Sender: TObject);
Var
F: TextFile;
i,j: Integer;
S: String;
begin
AssignFile(F, 'C:\1.txt');
Reset(F);
For i:= 0 To StringGrid1.ColCount - 1 Do
For j:= 0 To StringGrid1.RowCount - 1 Do
begin
Readln(F, S);
StringGrid1.Cells[i,j]:= S;
end;
CloseFile(F);
end;