【问题标题】:TColorbutton (Delphi XE5 - Mobile App) does not show text propertyTColorbutton(Delphi XE5 - 移动应用程序)不显示文本属性
【发布时间】:2014-04-06 00:03:12
【问题描述】:

我在 FireMonkey 移动应用程序的表单中使用了组件 TGridlayout

我想在运行时创建带有颜色、文本和图像的按钮。我正在使用TColorbuttonTimage 组件,但TColorbutton 只显示图片和颜色。在Text 属性中输入的文本不会出现。

如何动态创建按钮(带有颜色、图像和文本)?

【问题讨论】:

    标签: android delphi delphi-xe5 firemonkey-fm3


    【解决方案1】:

    您必须在按钮内动态创建一个 Tlabel。 例子在这里:

    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;
    

    注意:TColorButton.Create参数中使用的“panTastiera”是主窗体上的一个tpanel

    要添加图像,您可以执行相同的操作,动态创建 Timage。 在我的原始代码中,我创建了一个按钮数组,如图所示

    【讨论】:

    • 詹卢卡,谢谢您的回复。这正是我所需要的。
    猜你喜欢
    • 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
    相关资源
    最近更新 更多