Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make a control that can't contain other controls?

I'm designing a custom control, and every time I have it highlighted in the form designer and then pick another control from the control palette, the new one ends up inside my control, as if it were a TPanel or TGroupBox. This isn't what I want, so how can I keep it from happening?

like image 505
Mason Wheeler Avatar asked Dec 09 '22 19:12

Mason Wheeler


1 Answers

You need to remove the csAcceptsControls flag from the ControlStyle property, ideally directly in the constructor:

constructor TMyComponent.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  ControlStyle := ControlStyle - [csAcceptsControls];
  // more initialization stuff ...
end;
like image 179
mghie Avatar answered Dec 29 '22 01:12

mghie