【发布时间】:2013-07-15 14:59:41
【问题描述】:
我制作了一个 Firemonkey 自定义 ListBox 项,使用样式书设计。 当我尝试插入 ListBox 项时,一切正常(插入文本等),除了更改 ListBox 项中的图片。
我在 http://www.experts-exchange.com 上学习了本教程。
这是我的代码:
procedure TForm2.Button1Click(Sender: TObject);
var
i : Integer;
LBItem : TListBoxItem;
ItemImage : Timage;
begin
ListBox1.BeginUpdate;
ListBox1.Items.Clear;
try
for i := 0 to 9 do begin
LBItem := TListBoxItem.Create(nil);
LBItem.Parent := ListBox1;
LBItem.StyleLookup := 'rowLayout';
LBItem.StylesData['textName'] := 'Some text...';
LBItem.StylesData['textFormat'] := 'Some more text...';
ItemImage := LBItem.FindStyleResource('picture') as TImage;
if Assigned(ItemImage) then
LBItem.ItemData.Bitmap.LoadFromFile('D:\MyTestPicture.jpg');
end;
finally
ListBox1.EndUpdate;
end;
end;
“rowLayout”是我在样式书中的布局,我为 ListBox 项制作的。 “textName”和“textFormat”是一些 TText,我放在 ListBox 项中。 “图片”是我的 ListBox 项中的 TImage。
我的代码出了什么问题? 我正在使用 Delphi XE4。
感谢您的帮助和问候, 霍尔格
【问题讨论】:
标签: delphi listbox firemonkey listboxitem