Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Example TcxPropertiesStore.StoreTo

  • 2 minutes to read

The following example demonstrates how to use the TcxPropertiesStore component. Consider storing the Color property value of the cxStyle object. This object (cxTabStyle) is assigned to the RootLevelStyles.Tab property of a cxGrid control.

The TcxPropertiesStore component does not allow you to save/restore sub-properties of the properties referring to TComponent descendants. So, saving the Color property of a cxStyle object needs a special approach. The following code shows the correct method of saving the Color property of the cxTabStyle style:

//...
//setting the level tabs painting style to cxTabStyle
cxGrid1.RootLevelStyles.Tab := cxTabStyle;
with cxPropertiesStore1 do
begin
//adding a reference to the cxGrid1 control into the Components collection
     with TcxPropertiesStoreComponent(Components.Add) do
     begin
          Component := cxGrid1;
          //specifying the
          Properties.Add('RootLevelStyles.Tab');
     end;
//adding a reference to cxTabStyle into the Components collection
     with TcxPropertiesStoreComponent(Components.Add) do
     begin
          Component := cxTabStyle;
          //specifying the Color property for storing/restoring
          Properties.Add('Color');
     end;
//setting the storage type to INI file
     StorageType := stIniFile;
//specifying the name of the INI file
     StorageName := 'c:\store.ini';
//saving information
     StoreTo;
end;
//...

The result of this code execution is shown below:

[cxGrid1: TcxPropertiesStoreComponent]
=
RootLevelStyles.Tab=cxTabStyle
[cxTabStyle: TcxPropertiesStoreComponent]
=
Color=15451300

The resulting file contains all the required information – the RootLevelStyles.Tab style object and the Color property value for that object.