Back to Devexpress

TcxTreeListStorageOptions Type

vcl-cxtl-6bd3d4ef.md

latest9.1 KB
Original Source

TcxTreeListStorageOptions Type

A set of flags that correspond to individual Tree List user interaction states stored in a file, stream, or system registry.

Declaration

delphi
TcxTreeListStorageOptions = set of TcxTreeListStorageOption;

Referenced Class

TypeDescription
TcxTreeListStorageOption

A flag that corresponds to an individual Tree List user interaction state.

|

Remarks

A TcxTreeListStorageOptions value can include any TcxTreeListStorageOption flag to indicate required user interaction states.

You need to use tsoUseDataViewState with all required flags when you call the following methods to store/restore corresponding user interaction states (in addition to the data layout):

Tip

You can use only the cxTreeListStoreAllDataViewStates constant if you need to store all user interaction states (as demonstrated in the Code Examples section below).

Code Examples

Store Tree List State Between Sessions

The code example in this section demonstrates form OnDestroy and OnCreate event handlers. These handlers call StoreToStream and RestoreFromStream procedures to save and restore user interaction states (selection, focus, scroll position, etc.) in addition to the Tree List structure/data layout.

delphi
uses
  System.SysUtils, // Declares the FileExists function
  cxTL, // Declares TcxTreeList, TcxCustomTreeList, and related types
// ...

procedure TMyForm.FormCreate(Sender: TObject);
var
  AFileStream: TFileStream;
begin
  if FileExists('TreeListConfig.dat') then
  begin
    AFileStream := TFileStream.Create('TreeListConfig.dat', fmOpenReadWrite);
    try
      cxTreeList1.RestoreFromStream(AFileStream, True, False, '', cxTreeListStoreAllDataViewStates);
    finally
      AFileStream.Free;
    end;
  end;
end;

procedure TMyForm.FormDestroy(Sender: TObject);
var
  AFileStream: TFileStream;
begin
  AFileStream := TFileStream.Create('TreeListConfig.dat', fmCreate or fmOpenReadWrite);
  try
    cxTreeList1.StoreToStream(AFileStream, '', cxTreeListStoreAllDataViewStates);
  finally
    AFileStream.Free;
  end;
end;
cpp
#include "System.SysUtils.hpp" // Declares the FileExists function
#include "cxTL.hpp" // Declares TcxTreeList, TcxCustomTreeList, and related types

// Add the following linker directive to the corresponding CPP source file:
#pragma link "cxTL" // Required to use cxTL.hpp declarations

void __fastcall TMyForm::FormCreate(TObject *Sender)
{
  TFileStream *AFileStream;
  if(FileExists("TreeListConfig.dat"))
  {
    AFileStream = new TFileStream("TreeListConfig.dat", fmOpenReadWrite);
    try
    {
      cxTreeList1->RestoreFromStream(AFileStream, true, false, "", cxTreeListStoreAllDataViewStates);
    }
    __finally
    {
      delete AFileStream;
    }
  }
}

void __fastcall TMyForm::FormDestroy(TObject *Sender)
{
  TFileStream *AFileStream = new TFileStream("TreeListConfig.dat", fmCreate | fmOpenReadWrite);
  try
  {
    cxTreeList1->StoreToStream(AFileStream, "", cxTreeListStoreAllDataViewStates);
  }
  __finally
  {
    delete AFileStream;
  }
}

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:

delphi
uses
  FireDAC.Comp.Client, // Declares the TFDQuery component
  cxDBTL; // Declares the TcxDBTreeList class
// ...

  cxDBTreeList1.StoreDataViewState(cxTreeListStoreAllDataViewStates);
  FDQuery1.Refresh;
  cxDBTreeList1.RestoreDataViewState(cxTreeListStoreAllDataViewStates);
cpp
#include "FireDAC.Comp.Client.hpp" // Declares the TFDQuery component
#include "cxDBTL.hpp" // Declares the TcxDBTreeList class

// Add the following linker directives to the corresponding CPP source file:
#pragma link "FireDAC.Comp.Client" // Required to use FireDAC.Comp.Client.hpp declarations
#pragma link "cxDBTL" // Required to use cxDBTL.hpp declarations

  cxDBTreeList1->StoreDataViewState(cxTreeListStoreAllDataViewStates);
  FDQuery1->Refresh();
  cxDBTreeList1->RestoreDataViewState(cxTreeListStoreAllDataViewStates);

Direct TcxTreeListStorageOptions Type References

The following Tree List procedures accept a TcxTreeListStorageOptions value as a parameter (AOptions). This parameter allows you to store/restore user interaction states.

Tree List Information Store Procedures

TcxCustomTreeList.StoreDataViewStateStores specified user interaction states in memory.TcxCustomTreeList.StoreDataViewStateToStreamSaves specified user interaction states to a stream.TcxCustomTreeList.StoreToIniFileSaves Tree List state information to an INI file.TcxCustomTreeList.StoreToRegistrySaves Tree List state information to the system registry.TcxCustomTreeList.StoreToStreamSaves specified Tree List structure and user interaction information to a stream.

Tree List Information Restore Procedures

TcxCustomTreeList.RestoreDataViewStateRestores user interaction states stored in memory after a StoreDataViewState procedure call.TcxCustomTreeList.RestoreDataViewStateFromStreamRestores previously saved user interaction states from a stream.TcxCustomTreeList.RestoreFromIniFileRestores previously saved Tree List state information from an INI file.TcxCustomTreeList.RestoreFromRegistryRestores previously saved Tree List state information from the system registry.TcxCustomTreeList.RestoreFromStreamRestores a previously saved Tree List state from a stream. See Also

TcxGridStorageOptions Type

cxTL Unit