2016-03-29 36 views
3

德爾福XE-6創造firemonkey複合控件

我試圖創建TGroupBox,在那裏我的組合框中創建TGridPanelLayout Control派生自己的定製Firemonkey控制。

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

如何防止用戶能夠選擇和/或刪除TGridPanelLayout控件?在設計時,我只希望我的父控件(從TGroupbox派生)可以從表單中選擇和刪除。

回答

4

對於您不想在設計時選擇的每個子控件,您需要將Stored屬性設置爲false。例如,以下代碼將創建一個包含兩個子控件的面板:TEditTButton

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. 
+0

Ahhhhhhh - Thank You! – JakeSays