【问题标题】:How do I make a control that can't contain other controls?如何制作一个不能包含其他控件的控件?
【发布时间】:2009-10-01 13:34:03
【问题描述】:

我正在设计一个自定义控件,每次我在表单设计器中突出显示它,然后从控件面板中选择另一个控件时,新的控件最终都会出现在我的控件中,就好像它是一个 TPanel 或 TGroupBox。这不是我想要的,那我怎样才能避免它发生呢?

【问题讨论】:

    标签: delphi component-design


    【解决方案1】:

    您需要从ControlStyle 属性中删除csAcceptsControls 标志,最好直接在构造函数中:

    constructor TMyComponent.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
      ControlStyle := ControlStyle - [csAcceptsControls];
      // more initialization stuff ...
    end;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多