I am not that experienced programmer , so the code might be very poor in structure ...
So, the code looks like this , all works smooth until I close the program , then stringgrid reads txt file with xml ID's after that I press add button to add new user , unfortunatley program saves it to the 1st row again , which is overwriting provious data. All the var's are set to edit fields. I would like to add that when program is not closed it works as I want ,it adds 1st row then second and etc , problem is when I open the program again.
This is in unit 2 (form2) :
arow :=arow+ 1;
form1.stringgrid1.Cells[1,arow]:=name;
form1.stringgrid1.Cells[2,arow]:=surname;
form1.stringgrid1.Cells[3,arow]:=batch;
form1.stringgrid1.Cells[4,arow]:=agency;
form1.stringgrid1.Cells[5,arow]:=start;
form1.stringgrid1.Cells[6,arow]:=age;
form1.stringgrid1.Cells[7,arow]:=nat;
form1.stringgrid1.Cells[8,arow]:=phone;
form2.Close;
and that in unit1 ( form1) :
procedure TForm1.FormCreate(Sender: TObject);
begin
stringgrid1.col:=1;
stringgrid1.loadfromfile('test.txt');
end;
procedure TForm1.ButtonSave(Sender: TObject);
begin
stringgrid1.SaveToFile('test.txt');
end;
procedure TForm1.ButtonAdd(Sender: TObject);
begin
StringGrid1.SetFocus;
form2.Visible:=true;
end;