user3378944
user3378944

Reputation: 21

TColorbutton (Delphi XE5 - Mobile App) does not show text property

I'm using a component TGridlayout into a form in a FireMonkey Mobile Application.

I would like to create, at runtime, buttons with color, text and image. I am using TColorbutton and Timage components, but TColorbutton only shows the picture and color. The text entered in the Text property does not appear.

https://i.sstatic.net/nUN0S.png

How can I create buttons (with color, image and text) dynamically?

Upvotes: 2

Views: 923

Answers (1)

Gianluca Colombo
Gianluca Colombo

Reputation: 829

You have to create a Tlabel dinamically inside the button. The example is here:

var btn:TColorButton;
var testo:TLabel;

       btn:=TColorButton.Create(panTastiera);
       btn.Width:=200;
       btn.Height:=65;
       btn.Parent:=Form1;
       btn.Position.X:=10;
       btn.Position.Y:=10;

       testo:=TLabel.Create(btn);
       testo.Text:='Button 1';
       testo.OnClick:=btn.OnClick;
       testo.Parent:=btn;
       testo.FontColor:=$ffffff;
       testo.TextAlign:=TTextAlign.Center;
       testo.AutoSize:=true;
       testo.Align:=TAlignLayout.Client;

Note: "panTastiera" used in TColorButton.Create parameter, is a tpanel on the main form

To add image you can do the same, creating Timage dinamically. In my original code I created an array of buttons as the image shows

enter image description here

Upvotes: 2

Related Questions