制作包含其他组件的自定义组件的正确方法
Proper way to make custom component containing other components
我想制作我自己的包含其他组件的简单组件。看起来像:
TTag = class(TLayout)
private
_line: TLine;
_label: TLabel;
_background: TRoundRect;
_button: TLabel;
public
constructor Create(AOwner: TComponent); override;
end;
当我将此组件放在表单上时,一切正常,我的表单结构如下所示:
但在 Delphi IDE 重新打开后它看起来像:
如何添加子组件来避免这种奇怪的行为?
这是 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.
对于每个子组件,在构造函数中调用 SetSubComponent(True)
。
我想制作我自己的包含其他组件的简单组件。看起来像:
TTag = class(TLayout)
private
_line: TLine;
_label: TLabel;
_background: TRoundRect;
_button: TLabel;
public
constructor Create(AOwner: TComponent); override;
end;
当我将此组件放在表单上时,一切正常,我的表单结构如下所示:
但在 Delphi IDE 重新打开后它看起来像:
如何添加子组件来避免这种奇怪的行为?
这是 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.
对于每个子组件,在构造函数中调用 SetSubComponent(True)
。