Hello,
I use a helper to Store/Restore TcxCustomVerticalGrid to TStringStream. I have succesfully do simillar things for TcxCustomGridView,TdxLayoutContainer and TcxCustomPivotGrid without any problem.
But I have a problem with TcxVerticalGrid.
See full source and sample in attachment.
Delphitype
TcxTextStreamReader = class(TcxIniFileReader)
protected
procedure BeginRead; override;
function CanRead: Boolean; override;
end;
TcxTextStreamWriter = class(TcxIniFileWriter)
protected
procedure EndWrite; override;
end;
TcxCustomVerticalGridStoreHelper = class helper for TcxCustomVerticalGrid
procedure RestoreFromTextStream(AStream: TStream);
procedure StoreToTextStream(AStream: TStream);
private
end;
.../...
{ TcxCustomVerticalGridStoreHelper }
procedure TcxCustomVerticalGridStoreHelper.RestoreFromTextStream(AStream: TStream);
var
AStorage: TcxStorage;
begin
AStorage := TcxStorage.Create(AStream);
try
BeginUpdate;
try
AStorage.RestoreFrom(Self,TcxTextStreamReader);
finally
EndUpdate;
end;
finally
AStorage.Free;
end;
end;
procedure TcxCustomVerticalGridStoreHelper.StoreToTextStream(AStream: TStream);
var
AStorage: TcxStorage;
begin
AStorage := TcxStorage.Create(AStream);
try
BeginUpdate;
try
AStorage.ReCreate := False;
AStorage.StoreTo(Self,TcxTextStreamWriter);
finally
EndUpdate;
end;
finally
AStorage.Free;
end;
end;
{ TcxTextStreamReader }
procedure TcxTextStreamReader.BeginRead;
var
List: TStringList;
begin
if CanRead then
begin
List := TStringList.Create;
try
List.LoadFromStream(StorageStream);
IniFile.SetStrings(List);
finally
List.Free;
end;
end
else
IniFile.Clear;
end;
function TcxTextStreamReader.CanRead: Boolean;
begin
Result := (StorageStream <> nil) and (StorageStream.Size > 0);
end;
{ TcxTextStreamWriter }
procedure TcxTextStreamWriter.EndWrite;
var
List: TStringList;
begin
List := TStringList.Create;
try
IniFile.GetStrings(List);
List.SaveToStream(StorageStream);
finally
List.Free;
end;
end;
1) Click on "Store to Tstrings"
This do cxDBVerticalGrid1.StoreToTextStream(Astream);
C#=> Name of row is stored like this [cxDBVerticalGrid1/0: TcxDBEditorRow]
2) Click on "Restore to Tstrings"
This do cxDBVerticalGrid1.RestoreFromTextStream(Astream);
3) Click (again) to "Store to Tstrings"
This do cxDBVerticalGrid1.StoreToTextStream(Astream);
C#=> Name of row become stored like this [cxDBVerticalGrid1/cxDBVerticalGrid1RecId: TcxDBEditorRow] !!!
Why [cxDBVerticalGrid1/0: TcxDBEditorRow] become [cxDBVerticalGrid1/cxDBVerticalGrid1RecId: TcxDBEditorRow] ?
Best regards,
Fabrice
Hello,
We will examine your project, but it can take some time. We will get back to you once we have any results or need additional information. Thank you for your patience.