Page 1 of 1

TVirtualTable.LoadFromFile() problem

Posted: Thu 17 Jan 2013 06:40
by Lithiumâ„¢
Hello!
Could you help me please with TVirtualTable?

TVirtualTable has pair of methods:

Code: Select all

TVirtualTable.LoadFormFile(FileName: string; RestoreFields: boolean = TRUE);
TVirtualTable.SaveToFile(FileName: string; StoreFields: boolean = TRUE);
My form definition is:

Code: Select all

  TfrmMyForm = class(TForm)
    dstEvents: TVirtualTable;
    dstEventsSerial: TIntegerField;
    ...
  end;
I do the following:

Code: Select all

procedure TfrmMyForm.btnMyActionClick(Sender: TObject);
begin
  dstEvents.SaveToFile(dstEvents.Name + '.vtd');
  ...
  dstEvents.LoadFormFile(dstEvents.Name + '.vtd');
  ...
  dstEvents.Insert;
  // next row raises an error, because dstEventsSerial = nil
  dstEventsSerial.Value := dstEvents.RecordCount;
  dstEvents.Post;
end;
I have tried to set RestoreFields to FALSE and it works without any errors.
However, is it normal behavior when field refs are lost?

Thanks.

Re: TVirtualTable.LoadFromFile() problem

Posted: Thu 17 Jan 2013 11:34
by AlexP
Hello,

This is the correct behavior. To make fields not cleared, you should set the parameter LoadFields of the LoadFromFile method to False