I am developing a program and I have a StringGrid on it; when a particular button is pressed, my program saves the stringgtid into c:\myfolder\tab9.txt. I would like to put a progress bar that indicate how many time remains at the end of the saving process because sometime the grid has a lot of rows and it could take some time. I am using this code:
procedure SaveSG(StringGrid:TStringGrid; const FileName:TFileName);
var
f: TextFile;
i,k: Integer;
begin
AssignFile(f, FileName);
Rewrite(f);
with StringGrid do
begin
Writeln(f, ColCount); // Write number of Columns
Writeln(f, RowCount); // Write number of Rows
for i := 0 to ColCount - 1 do // loop through cells of the StringGrid
for k := 0 to RowCount - 1 do
Writeln(F, Cells[i, k]);
end;
CloseFile(F);
end;
I call the procedure in this way: SaveSG(StringGrid1,'c:\myfolder\myfile.txt');
. My problem is that I don't understand how to do a progress bar that indicate the progress of the saving. At the moment I've only declared ProgressBar1.Position:=0
and ProgressBar1.Max:=FileSize
. Do you have any suggestions?