[Lazarus] Stream a property (string) of a TCollection derived component to LFM

Bart bartjunk64 at gmail.com
Sun Jan 12 16:39:55 CET 2014


Hi,

I'm stuck.

Consider this situation.

type

  TTitle = class(TPersistent)
  ....
  published
    property Caption: String read GetCaption write SetCaption stored
IsCaptionStored;
  end;

  TItem = class(TCollectionItem)
  ...
  public
    property Title: TTitle read GetTitle write SetTitle;
  end;

  TCol = class(TCollection)
  private
    FProp: String;
    ...
    function IsPropStored;  //returns True
    ...
  published
    ...
    property Prop: String read FProp write FProp stored IsPropStored;
    property Items[Index: Integer]: TItem read GetItem write SetItem; default;
  end;

  TExample = class(TCustomControl)
  private
    FCol: TCol;
  ...
  published
    ...
    property Col: TCol read GetCol write GetCol stored IsColStored;
  end;

Now I drop a TExample on a form.
In OI I click on property Col and add some items.
I save the project and restart Lazarus and my Col property properly
has its Items.

    Col = <
      item
        Title.Caption = 'Title'
      end
      item
        Title.Caption = 'Title'
      end>

However the property Prop does not get written to the LFM.
FWIW: All of the IsXXXStored functions return True.

(For those who rather know what I'm actually doing:

- TExample = TCustomGrid
- TCol = TGridColumns
- TItem = TGridColumn
- TTitle = TGridColumnTitle

I want to implement a published DefaultCaption: string; property for
TGridColums.
)

How do I make that work?
Do I need to override TExample.DefineProperties?

Bart




More information about the Lazarus mailing list