如何以编程方式在TListBoxItem中添加图像? [英] How can I programatically add an image inside a TListBoxItem?

查看:180
本文介绍了如何以编程方式在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.

这篇关于如何以编程方式在TListBoxItem中添加图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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