Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

TdxCustomMemData.SaveToStream(TStream) Method

Saves stored data to a stream.

#Declaration

Delphi
procedure SaveToStream(AStream: TStream); dynamic;

#Parameters

Name Type Description
AStream TStream

The target stream.

#Remarks

Call the SaveToStream procedure to save all stored dataset records to a stream.

#Code Example: Copy Data Between Datasets

The following code example copies data between two memory-based datasets through a stream:

var
  AStream: TMemoryStream;
begin
  AStream := TMemoryStream.Create;  // Creates a memory stream
  try
    dxMemData1.SaveToStream(AStream); // Saves data from the first dataset to the created stream
    AStream.Position := 0;  // Resets the current position to 0 after a data save operation
    dxMemData2.DisableControls;  // Disables data synchronization with bound controls
    try
      dxMemData2.LoadFromStream(AStream);  // Loads previously saved data to the second dataset
    finally
      dxMemData2.EnableControls;  // Re-enables data synchronization with bound controls
  finally
    AStream.Free;  // Releases the memory stream regardless of the operation's success
end;
See Also