如何向我的 VCL 组件添加按钮

how can i add a button to my VCL Component

我已经创建了一个组件,现在我想给它添加一个按钮。
我试着像这样创建按钮:

constructor TUiCompU.Create(AOwner: TComponent);
begin
inherited;

  FButton := TButton.Create(Self);
....
End;

但是按钮没有显示。
我该怎么做?

您不仅需要 Create() 按钮,还需要将其 Parent 属性 设置为您的组件:

FButton.Parent := Self;