如何以编程方式在TListBoxItem中添加图像?
很长一段时间,我使用自定义样式加载详细的 TListBox
。
For a long time, I was using a Custom Style to load a detailed TListBox
.
它基本上是 ListBox
,其中 TImage
icon.
It's basically a ListBox
with a TImage
as an icon.
然而,最近我遇到了很多错误,并决定全力以赴。
However recently I've been encountering lots of bugs and decided to throw it all away.
这是我以编程方式生成 TListBox
项目的方式:
This is how I generate my TListBox
items programatically:
// Create LISTBox Item
lb_item := TListBoxItem.Create(self);
lb_item.Parent := lb_awesome_list;
lb_item.Text := cow_name;
如果我想添加图像
怎么办? >到它?
我试图将它添加为ItemData
I've tried to add it as an ItemData
lb_item.ItemData.Bitmap := iv_user_ic.Bitmap;
还有一些其他选项没有成功。是否可以以编程方式添加图像?
And a few other options without success. Is it possible to add an image programatically?
设置 ItemData.Bitmap的方法
属性是一个好的开始。现在,您必须选择适当的项目样式以显示位图。 F.i. listboxitemleftdetail 应该这样做。
The approach with setting the ItemData.Bitmap
property is a good start. Now you have to select an appropriate item style to show the bitmap. F.i. listboxitemleftdetail should do.