19th
Май

Сохранение и чтение файла в StringGrid

Posted by Chas under Пост-обзор

Вообщем мне нужно заполнить 6 ячеек, сохранить, а после при загрузке чтобы всё читалось и редактировалось.

Anny_Apple:

Сохранение и чтение TStringGrid  

procedure SaveGrid;
var
f: textfile;
x, y: integer;
begin
assignfile(f, 'Filename');
rewrite(f);
writeln(f, stringgrid.colcount);
writeln(f, stringgrid.rowcount);
for X := 0 to stringgrid.colcount - 1 do
for y := 0 to stringgrid.rowcount - 1 do
writeln(F, stringgrid.cells[x, y]);
closefile(f);
end;

procedure LoadGrid;
var
f: textfile;
temp, x, y: integer;
tempstr: string;
begin
assignfile(f, 'Filename');
reset(f);
readln(f, temp);
stringgrid.colcount := temp;
readln(f, temp);
stringgrid.rowcount := temp;
for X := 0 to stringgrid.colcount - 1 do
for y := 0 to stringgrid.rowcount - 1 do
begin
readln(F, tempstr);
stringgrid.cells[x, y] := tempstr;
end;
closefile(f);
end;

тема на форуме

Похожие статьи