TcxTreeListStorageOptions Type
A set of flags that correspond to individual Tree List user interaction states stored in a file, stream, or system registry.
Declaration
TcxTreeListStorageOptions = set of TcxTreeListStorageOption;
Referenced Class
Type | Description |
---|---|
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):
- TcxCustomTreeList.StoreToIniFile | TcxCustomTreeList.RestoreFromIniFile
- TcxCustomTreeList.StoreToRegistry | TcxCustomTreeList.RestoreFromRegistry
- TcxCustomTreeList.StoreToStream | TcxCustomTreeList.RestoreFromStream
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.
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;
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);
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.StoreDataViewState
- Stores specified user interaction states in memory.
- TcxCustomTreeList.StoreDataViewStateToStream
- Saves specified user interaction states to a stream.
- TcxCustomTreeList.StoreToIniFile
- Saves Tree List state information to an INI file.
- TcxCustomTreeList.StoreToRegistry
- Saves Tree List state information to the system registry.
- TcxCustomTreeList.StoreToStream
- Saves specified Tree List structure and user interaction information to a stream.
Tree List Information Restore Procedures
- TcxCustomTreeList.RestoreDataViewState
- Restores user interaction states stored in memory after a StoreDataViewState procedure call.
- TcxCustomTreeList.RestoreDataViewStateFromStream
- Restores previously saved user interaction states from a stream.
- TcxCustomTreeList.RestoreFromIniFile
- Restores previously saved Tree List state information from an INI file.
- TcxCustomTreeList.RestoreFromRegistry
- Restores previously saved Tree List state information from the system registry.
- TcxCustomTreeList.RestoreFromStream
- Restores a previously saved Tree List state from a stream.