【问题标题】:creating composite controls in firemonkey在 firemonkey 中创建复合控件
【发布时间】:2016-07-17 13:36:29
【问题描述】:

德尔福 XE-6

我正在尝试创建我自己的从 TGroupBox 派生的自定义 Firemonkey 控件,在这里我在 groupbox 上创建了一个 TGridPanelLayout 控件。

constructor TMyRadioGroup.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FLayout:= TGridPanelLayout.Create(self);
  FLayout.Parent:= self;
end;

如何防止用户选择和/或删除 TGridPanelLayout 控件?在设计时,我只希望我的父控件(从 TGroupbox 派生)可以从表单中选择和删除。

【问题讨论】:

    标签: delphi firemonkey


    【解决方案1】:

    对于您不想在设计时选择的每个子控件,您需要将Stored 属性设置为false。例如,以下代码创建一个面板,其中包含两个子控件,一个 TEdit 和一个 TButton

    unit PanelCombo;
    
    interface
    
    uses
      System.SysUtils, System.Classes, FMX.Types, FMX.Controls,
      FMX.Controls.Presentation, FMX.StdCtrls, FMX.Edit;
    
    type
      TPanelCombo = class(TPanel)
      private
        { Private declarations }
        edit1: TEdit;
        button1: TButton;
      protected
        { Protected declarations }
      public
        { Public declarations }
         constructor Create(AOwner: TComponent); override;
         destructor Destroy; override;
      published
        { Published declarations }
      end;
    
    procedure Register;
    
    implementation
    
    procedure Register;
    begin
      RegisterComponents('Samples', [TPanelCombo]);
    end;
    
    constructor TPanelCombo.Create(AOwner: TComponent);
    begin
      inherited;
      edit1:= TEdit.create(self);
      edit1.parent:= self;
      edit1.align:= TAlignLayout.Top;
      edit1.stored:= false;
    
      button1:= TButton.create(self);
      button1.parent:= self;
      button1.align:= TAlignLayout.bottom;
      button1.stored:= false;
    end;
    
    destructor TPanelCombo.Destroy;
    begin
      inherited;
      edit1.Free;
      button1.Free;
    end;
    
    end.
    

    【讨论】:

    • 啊啊啊啊——谢谢!
    猜你喜欢
    • 1970-01-01
    • 2010-11-12
    • 2014-06-19
    • 2012-06-09
    • 2014-02-04
    • 2014-08-22
    • 2013-06-25
    • 1970-01-01
    • 2011-12-02
    相关资源
    最近更新 更多