Skip to main content

Example: TcxCustomDataController.SaveToStream, TcxCustomDataController.LoadFromStream

The SaveToStream and LoadFromStream methods provided by a data controller enable you to save and restore data in unbound loading mode.

The following example shows how to save information and restore it from a file for the tvPlanets view in ExpressQuantumGrid.

var
  AStream: TStream;
//...
//Saving data to a file
  AStream := TFileStream.Create('e:\stream.txt', fmCreate);
  try
    tvPlanets.DataController.SaveToStream(AStream);
  finally
    AStream.Free;
  end;
//...
//Loading data from the file
  AStream := TFileStream.Create('e:\stream.txt', fmOpenRead);
  try
    tvPlanets.DataController.LoadFromStream(AStream);
  finally
    AStream.Free;
  end;