2014-07-14 3 views
0

다음은 셀에 버튼을 표시하려는 경우 Delphi XE5에서 작동합니다. 그러나 델파이 XE6에서는 그렇지 않습니다.어떻게 격자 셀 firemonkey xe6에 단추를 삽입 할 수 있습니까?

Type 
    TSimpleLinkCell = class(TTextCell) 
    protected 
     FButton: TSpeedButton; 
     procedure ButtonClick(Sender: TObject); 
    public 
     constructor Create(AOwner: TComponent); reintroduce; 
    end; 

constructor TSimpleLinkCell.Create(AOwner: TComponent); 
begin 
    inherited Create(AOwner); 
    Self.TextAlign := TTextAlign.taLeading; 
    FButton := TSpeedButton.Create(Self); 
    FButton.Parent := Self; 
    FButton.Height := 16; 
    FButton.Width := 16; 
    FButton.Align := TAlignLayout.alRight; 
    FButton.OnClick := ButtonClick; 
end; 

어떻게하면 위의 작업을 Delphi XE6에서 만들 수 있습니까?

+0

나는 당신이 대답을 테스트했습니다 그것은 작동합니다. 올바른 응답이라고 말할 수 있습니까? 부디! –

답변

1
  1. 귀하의 SpeedButton 당신이 그리드에이 객체를 삽입 TColumn 유형을하면 마우스
  2. 와 버튼에 갔다 때까지 그렇게 아무것도 표시되지 않습니다 텍스트가 없습니다, 그것은 작동합니다. 여기에 완전히 (XE4 테스트) 코드의 예를 노력하고 있습니다 :

    unit Unit5; 
    
    interface 
    
    uses 
        System.SysUtils, System.Types, System.UITypes, System.Rtti, System.Classes, 
        System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, 
        FMX.StdCtrls, FMX.Layouts, FMX.Grid; 
    
    type 
        TSimpleLinkCell = class(TTextCell) 
        protected 
         FButton: TSpeedButton; 
         procedure ButtonClick(Sender: TObject); 
        public 
         constructor Create(AOwner: TComponent); reintroduce; 
        end; 
    
        TButtonColumn=class(TColumn) 
        protected 
        function CreateCellControl: TStyledControl;override; 
        end; 
    
        TForm5 = class(TForm) 
        Grid1: TGrid; 
        procedure FormCreate(Sender: TObject); 
        private 
        { Private declarations } 
        public 
        { Public declarations } 
        end; 
    
    var 
        Form5: TForm5; 
    
    implementation 
    {$R *.fmx} 
    
    constructor TSimpleLinkCell.Create(AOwner: TComponent); 
    begin 
        inherited Create(AOwner); 
        Self.TextAlign := TTextAlign.taLeading; 
        FButton := TSpeedButton.Create(Self); 
        FButton.Parent := Self; 
        FButton.Height := 16; 
        FButton.Width := 16; 
        FButton.Align := TAlignLayout.alRight; 
        FButton.OnClick := ButtonClick; 
    // FButton.Text:='Button'; 
    end; 
    
    procedure TSimpleLinkCell.ButtonClick(Sender: TObject); 
    begin 
        ShowMessage('The button is clicked!'); 
    end; 
    
    function TButtonColumn.CreateCellControl: TStyledControl; 
    var 
        cell:TSimpleLinkCell; 
    begin 
        cell:=TSimpleLinkCell.Create(Self); 
        Result:=cell; 
    end; 
    
    procedure TForm5.FormCreate(Sender: TObject); 
    begin 
        Grid1.AddObject(TButtonColumn.Create(Grid1)); 
    end; 
    
    end. 
    
관련 문제