创建特定的自定义TListBoxItem与给定的例子和与fontColor属性的麻烦 [英] Creating specific Custom TListBoxItem with given example and trouble with fontColor property

查看:866
本文介绍了创建特定的自定义TListBoxItem与给定的例子和与fontColor属性的麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



有人可以指导我正确的方向。我正在尝试使用Delphi XE4为iOS应用程序创建一个Custom ListboxItem。我的目标输出将是上面照片的一部分,在那里我正在卡在这里(下图)。


Can someone please guide me in the right direction. I am attempting to create a Custom ListboxItem using Delphi XE4 for a iOS application. My goal output would be something along the lines of the photo above, where as I am currently stuck here (image below).

我已经成功地动态生成ListBoxItem并插入了一个TLabel对象,但是我无法将TLabel的fontColor属性更改为所需的颜色。我可以编码

I have been successful at dynamically generating a ListBoxItem and inserting an TLabel object, however, I am unable to change the 'fontColor' property of the TLabel to a desired color. I can code

TLabel.Fontcolor:= ClaBlue;

TLabel.Fontcolor := ClaBlue;

但颜色恢复为黑色。我理想的喜欢它就像我给的例子。我有麻烦改变插入的TLabel的字体颜色,并添加渐变背景到每个Listbox项目。我不知道我是否需要使用样式编辑器,甚至是如何使用。是的,我看过Delphi / RAD Studio中的样本
这里是我目前的编码如下:

But the color reverts to black. I would ideal like it to look just like the example one I give. I am having troubles changing the font color of the inserted TLabel, and adding a gradient background to each Listbox Item. I do not know if I need to use a 'Style editor', or even how. And yes, I have looked at the sample included in Delphi/RAD Studio Here is my current coding below:

while XMLNode<>nil do begin 

HeaderText := 'Part#: ' + XMLNode.ChildNodes['PARTNUM'].Text + Chr(9) + XMLNode.ChildNodes['VENDPARTNUM'].Text;

DetailText := '$' + XMLNode.ChildNodes['MD1_SELL_PRICE'].Text + ' /' + XMLNode.ChildNodes['UM1_PRICE_NAME'].Text + sLineBreak + 'Min: ' + XMLNode.ChildNodes['md2_from.MD2_MIN_QTY'].text + Chr(9) + 'On Hand: ' + XMLNode.ChildNodes['md2_from.MD2_ON_HAND_QTY'].text + Chr(9) + Label1.text ;
Form6.ListBox1.Items.Add(DetailText); 
ListBoxItem:=Form6.ListBox1.ListItems[Form6.ListBox1.Items.Count-1]; 
ListBoxItem.StyleLookup:='listboxitembottomdetail';
ListBoxItem.WordWrap:=True; 
ListBoxItem.Font.Size:= 8;
ListBoxItem.Height := 120; 
TestLabel := TLabel.Create(self); 
TestLabel.Text := HeaderText; 
TestLabel.font.size := 20; 
testLabel.FontColor := claBlue; 
TestLabel.Width := form6.ListBox1.ClientWidth;
i := i +1; 
XMLNode := XMLNode.NextSibling;
end; 
Form6.ListBox1.EndUpdate;
Form6.Show;


推荐答案

您必须使用Style Book,
使用delphi附带的 CustomListBox 示例来了解如何在Firemonkey中正确使用样式。

You have to use the Style Book, use the CustomListBox sample that ships with delphi to learn how to properly use Styles in Firemonkey.

它也不会伤害阅读一些官方Firemonkey风格指南介绍
,例如使用样式自定义FireMonkey应用程序

It also wouldn't hurt to read through some of the official Firemonkey style guides for introduction
such as Customizing FireMonkey Applications with Styles.

看起来更复杂,那么简而言之就是产生你想要的结果:

It looks more complicated then it is, in short to produce the result you want to :


  1. 访问组件的样式设计器

  2. 通过结构窗口编辑/添加/删除和修改控件,在您的情况下,它将是 TText 控制组织在 Tlayouts

  3. 保存修改后,您可以在运行时更改特定TText控件的颜色: Item.StylesData ['TestLabel.Color']:= TAlphaColors.Red; (其中Item是一个TListboxitem)

  1. Access the Style designer of the component
  2. Via structure window edit/add/delete and modify controls, in your case it will be a combination of TText Controls organized in Tlayouts.
  3. Once you've saved your modifications, you can change the color of a specific TText control at runtime: Item.StylesData['TestLabel.Color'] := TAlphaColors.Red; ( where Item is a TListboxitem )

您尝试实现的并不难,通过实践学习处理风格设计师,纯粹的试用版和错误,并不像外观那么复杂。

What you are trying to achieve is not hard, learn handling the Style Designer via practice, pure trial and error, it's not as complicated as it looks.

这篇关于创建特定的自定义TListBoxItem与给定的例子和与fontColor属性的麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆