Back to Devexpress

TdxCustomMemData.LoadFromStream(TStream) Method

vcl-dxmdaset-dot-tdxcustommemdata-dot-loadfromstream-x28-system-dot-classes-dot-tstream-x29.md

latest3.0 KB
Original Source

TdxCustomMemData.LoadFromStream(TStream) Method

Loads data from a stream in the internal data format.

Declaration

delphi
procedure LoadFromStream(AStream: TStream); dynamic;

Parameters

NameTypeDescription
AStreamTStream

The target stream populated by a SaveToStream procedure call.

|

Remarks

Call the LoadFromStream procedure to populate the memory-based dataset from a stream previously populated by a SaveToStream procedure call.

Code Example: Copy Data Between Datasets

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

delphi
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;
cpp
TMemoryStream *AStream;
  // ...
  AStream = new TMemoryStream(); // 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
  {
    delete AStream; // Releases the memory stream regardless of the operation's success
  }

See Also

TdxCustomMemData.LoadFromBinaryFile Procedure

TdxCustomMemData.LoadFromDataSet Procedure

TdxCustomMemData.LoadFromStrings Procedure

TdxCustomMemData.LoadFromTextFile Procedure

TdxCustomMemData.SaveToStream Procedure

TdxCustomMemData Class

TdxCustomMemData Members

dxmdaset Unit