Ticket Q579845
Visible to All Users
Duplicate

TcxVerticalGrid helper to Store/restore from TStringStream

created 11 years ago

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.

Delphi
type 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

Comments (1)
DevExpress Support Team 11 years ago

    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.

    Answers approved by DevExpress Support

    created 11 years ago (modified 11 years ago)

    Hello,
    We've examined your code and determined that it is incorrect for VerticalGrid.
    If you wish to make your code workable, it is necessary to modify our source code. Make the FNewLoadMode parameter protected (FNewLoadMode supports the old format and now it is private) in the cxVGrid unit and change this parameter in the RestoreFromTextStream/StoreToTextStream procedures to False/True:

    Delphi
    procedure TcxCustomVerticalGridStoreHelper.RestoreFromTextStream(AStream: TStream); var AStorage: TcxStorage; begin NewLoadMode := False; AStorage := TcxStorage.Create(AStream); ... procedure TcxCustomVerticalGridStoreHelper.StoreToTextStream(AStream: TStream); var AStorage: TcxStorage; begin NewLoadMode := True; AStorage := TcxStorage.Create(AStream); ...

    P.S.: I've created a separate ticket to make the FNewLoadMode parameter protected: S173543: Introduce a property providing access to the FNewLoadMode field declared in the TcxCustomVerticalGrid class

      Comments (1)

        Hello,
        Thank you very much it's work like charm now.
        I have just added "BeforeLoadedRows;" and "AfterLoadedRows;" that miss in my RestoreFromTextStream procedure.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.