Q: How do I populate a TStringGrid with strings from a file...and save the strings after user editing back to a file?
A:
procedure TForm1.Button1Click(Sender: TObject);
var
F: System.Text;
S: String;
I: Integer;
begin
AssignFile(F, 'C:\AUTOEXEC.BAT');
Reset(F);
I := 1;
while not Eof(F) do
begin
ReadLn(F, S);
StringGrid1.Cells[1, I] := S;
Inc(I);
end;
CloseFile(F);
AssignFile(F, 'C:\CONFIG.SYS');
Reset(F);
I := 1;
while not Eof(F) do
begin
ReadLn(F, S);
StringGrid1.Cells[2, I] := S;
Inc(I);
end;
CloseFile(F);
end;