{ Function FileToStringGrid params in : StringGrid : référence d'un stringGrid FileNAme : nom du fichier à partir duquel lire les données} procedure FileToStringGrid(StringGrid: TStringGrid; FileName: String); var F: TextFile; Tmp, x, y: Integer; TmpStr: string; begin AssignFile(F, FileName); Reset(F); try Readln(F, Tmp); StringGrid.ColCount:=Tmp; Readln(F, Tmp); StringGrid.RowCount:=Tmp; for x:=0 to StringGrid.ColCount-1 do for y:=0 to StringGrid.RowCount-1 do begin Readln(F, TmpStr); StringGrid.Cells[x,y]:=TmpStr; end; finally CloseFile(F); end; end; { procedure StringGridToFile params in : StringGrid : référence sur un StringGrid FileName : nom du fichier de sauvegarde des données contenues dans StringGrid } procedure StringGridToFile(StringGrid: TStringGrid; FileName: String); var F: TextFile; x, y: Integer; begin AssignFile(F, FileName); Rewrite(F); try 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]); finally CloseFile(F); end; end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question