Skip to main content

TcxCustomTreeList.OnInitStoredObject Event

Enables you to initialize columns that are created when restoring the tree list’s layout from external data stores.

Declaration

property OnInitStoredObject: TcxInitStoredObjectEvent read; write;

Remarks

When the tree list’s layout is restored from a data store by calling the RestoreFromIniFile, RestoreFromRegistry, or RestoreFromStream method, and a data store column is missing in the TreeList control, this column is automatically created in the tree list, provided that the method is called with True passed as the AChildrenCreating parameter. After it’s been created, the OnInitStoredObject event is fired. You can handle this event to properly initialize the object which corresponds to the created column. Initialization includes re-associating column events with existing event handlers and assigning column properties.

The TreeList control being restored from a data store and the column that has been created are passed as the Sender and AObject parameters of the OnInitStoredObject event, respectively.

The following code represents the OnInitStoredObject event handler, demonstrating how to re-associate the events of all the columns (no specific identification is made) whose property storing and restoring is customized by handling a column’s OnGetStoredProperties, OnGetStoredPropertyValue and OnSetStoredPropertyValue events with existing event handlers (the ColumnGetStoredProperties, ColumnGetStoredPropertyValue and ColumnSetStoredPropertyValue procedures, respectively).

procedure TMyForm.cxTreeList1InitStoredObject(Sender, AObject: TObject);
var
  AColumn: TcxTreeListColumn;
begin
  if AObject is TcxTreeListColumn then
  begin
    AColumn = TcxTreeListColumn(AObject);
    AColumn.OnGetStoredProperties := ColumnGetStoredProperties;
    AColumn.OnGetStoredPropertyValue := ColumnGetStoredPropertyValue;
    AColumn.OnSetStoredPropertyValue := ColumnSetStoredPropertyValue;
    end;
end;
See Also