Reputation: 565
I want make my own simple component which contains other components. It looks like:
TTag = class(TLayout)
private
_line: TLine;
_label: TLabel;
_background: TRoundRect;
_button: TLabel;
public
constructor Create(AOwner: TComponent); override;
end;
When I put this component on form everything is ok and my form structure looks like:
but after Delphi IDE reopen it's looks like:
How add sub-components to avoid this strange behavior?
Upvotes: 3
Views: 2073
Reputation: 47694
That is a typical case for SetSubComponent:
Call SetSubComponent to indicate whether this component is a subcomponent. A subcomponent is a component whose Owner is a component other than the form or data module in which it resides. Unless such a component calls SetSubComponent with IsSubComponent set to True, its published properties will not be saved to the form file.
For each of your sub-components make a call to SetSubComponent(True)
in your constructor.
Upvotes: 8