Skip to main content
All docs
V25.1
  • TcxCustomTreeList.StoreDataViewState(TcxTreeListStorageOptions) Method

    Stores specified user interaction states in memory.

    Declaration

    procedure StoreDataViewState(AOptions: TcxTreeListStorageOptions);

    Parameters

    Name Type Description
    AOptions TcxTreeListStorageOptions

    Specifies a set of individual user interaction states stored in memory.

    Remarks

    Call StoreDataViewState and RestoreDataViewState procedures to save and restore specified user interaction states (selection, focus, node expanded status, etc.) during the same session.

    Note

    A RestoreDataViewState call clears all user interaction states saved using the StoreDataViewState procedure.

    If you need to store user interaction states in a stream, call StoreDataViewStateToStream and RestoreDataViewStateFromStream procedures.

    Tree List User Interaction States

    Pass a set of all required flags[1] as the AOptions parameter to restore corresponding Tree List user interaction states:

    tsoFocusedItem | tsoFocusedRecord
    Store the focus position.
    tsoSelected
    Stores selection.
    tsoTopRecord
    Stores the Tree List scroll position (the record at the top control border).
    tsoExpanded
    Stores the expanded status for all nodes.

    Note

    The tsoUseDataViewState flag has no effect on StoreDataViewState/RestoreDataViewState and StoreDataViewStateToStream/RestoreDataViewStateFromStream calls.

    Use tsoUseDataViewState in StoreToIniFile/RestoreFromIniFile, StoreToRegistry/RestoreFromRegistry, and StoreToStream/RestoreFromStream calls to save/restore user interaction states in addition to the data layout.

    Code Example: Restore User Interaction States after Data Refresh

    The following code example restores selection, focus and scroll positions, and node expanded states after a refresh operation in the bound dataset:

    uses
      FireDAC.Comp.Client,  // Declares the TFDQuery component
      cxDBTL;  // Declares the TcxDBTreeList class
    // ...
    
      cxDBTreeList1.StoreDataViewState(cxTreeListStoreAllDataViewStates);
      FDQuery1.Refresh;
      cxDBTreeList1.RestoreDataViewState(cxTreeListStoreAllDataViewStates);
    

    Other Tree List Store/Restore Methods

    Alternatively, you can store Tree List data layout and user interaction states in an INI file or the system registry. The TcxCustomTreeList class implements the following Store~/Restore~ method pairs in addition to StoreDataViewState and RestoreDataViewState:

    StoreToIniFile | RestoreFromIniFile
    Allow you to store the Tree List state (both data layout and user interaction states) in an INI file.
    StoreToRegistry | RestoreFromRegistry
    Allow you to store the Tree List state (both data layout and user interaction states) in the system registry.
    StoreToStream | RestoreFromStream
    Allow you to store the Tree List state (both data layout and user interaction states) in a stream.
    StoreDataViewStateToStream | RestoreDataViewStateFromStream
    Allow you to store user interaction states in a separate stream.
    Footnotes
    1. Alternatively, you can use only the cxTreeListStoreAllDataViewStates constant if you need to restore all user interaction states for the Tree List control as demonstrated in the code example in this topic.

    See Also