如何将Tstring网格中的选定行传递给此deleteFromfile过程。前两个过程使我能够删除Tstring网格中的选定行。因此从TString Grid中删除记录。但是记录存储在文件中。我需要从文件中删除记录以及从Tstring网格中删除记录。
procedure DeleteCurrentRow(Grid: TStringGrid);
var
i: Integer;
begin
for i := Grid.Row to Grid.RowCount - 2 do
Grid.Rows[i].Assign(Grid.Rows[i + 1]);
Grid.RowCount := Grid.RowCount - 1;
end;
procedure TManageUsersForm.RemoveUserButtonClick(Sender: TObject);
begin
UserStringGrid.Options := UserStringGrid.Options + [goEditing];
UserStringGrid.Options := UserStringGrid.Options + [goRowSelect];
DeleteCurrentRow(UserStringGrid);
end;
procedure DeleteFromfile();
begin
if messagedlg('Are you sure you want to Delete this record?',
mtconfirmation, [mbYes, mbNo], 0) = mrYes
then
begin
reset (UserFile);
seek (UserFile, FileSize(UserFile) –1);
read (UserFile, User);
seek (UserFile, recordposition);
write (UserFile, User);
seek (UserFile, FileSize(UserFile) –1);
truncate (UserFile);
closefile (UserFile);
end
{endif}
end;