Storing And Restoring The ExpressVerticalGrid Layout
- 2 minutes to read
The ExpressVerticalGrid control provides a means to save and restore its layout. This functionality is encapsulated in a series of methods:
Method | Description |
---|---|
StoreToIniFile | Stores the vertical grid layout to an INI-file. |
RestoreFromIniFile | Restores the vertical grid layout from an INI-file. |
StoreToRegistry | Stores the vertical grid layout to a registry key. |
RestoreFromRegistry | Restores the vertical grid layout from a registry key. |
StoreToStream | Stores the vertical grid layout to a stream. |
RestoreFromStream | Restores the vertical grid layout from a stream. |
The above mentioned methods save and restore the layout information, which includes:
the vertical grid control Name, OptionsView.RowHeaderWidth and OptionsView.ValueWidth property values;
the row class name and Height, Visible, Expanded and Index property values;
the row position within the hierarchy (ParentID attribute, specifying the Index property value of the owning row).
Examples of saving the ExpressVerticalGrid layout are demonstrated below:
- Using the StoreToIniFile method:
cxDBVerticalgrid.StoreToIniFile('c:\storetest.ini');
The storetest.ini file portion is demonstrated below:
[cxDBVerticalGrid: TcxDBVerticalGrid]
=
HeaderWidth=220
ValueWidth=171
[cxDBVerticalGrid/0: TcxCategoryRow]
=
AParentID=-1
Index=0
Visible=True
Height=-1
Expanded=True
[cxDBVerticalGrid/1: TcxDBMultiEditorRow]
=
AParentID=0
Index=0
Visible=True
Height=-1
Expanded=True
[cxDBVerticalGrid/2: TcxDBMultiEditorRow]
=
AParentID=0
Index=1
Visible=True
Height=-1
Expanded=True
[cxDBVerticalGrid/3: TcxCategoryRow]
=
AParentID=-1
Index=1
Visible=True
Height=-1
Expanded=True
- Using the StoreToRegistry method. Keep in mind, that this method by default stores the layout to the HKEY_CURRENT_USER registry key. The string parameter accepted by this method represents the registry key suffix.
cxDBVerticalgrid.StoreToRegistry('VGrid\StoreTest');
The system registry key which represents the stored layout is demonstrated in the following screenshot:
Note
the number of rows within the vertical grid control must remain the same between saving and restoring, otherwise restoring will fail.