TListView 项目焦点主题
当使用 TListView 并且在应用程序中禁用主题时,聚焦和选定的项目将显示如下所示:
请注意两个图像中三角形的位置。项目的绘制框不会绘制在图标出现的位置。在 TListBox 中,绘制的项目填充整个选定的项目。
我怎样才能像填充文本部分一样填充所选项目的图标部分?
我知道 TListBox 像这样呈现,但我需要使用 TListView 作为 Data 属性,而且 TListView 通过 TImageList 更好地处理图标。
谢谢。
When using a TListView and themes are disabled in the Application, the focused and selected item appears something like this:
Notice in both images where the triangle is. The painted box for the item does not draw where the icon appears. In a TListBox the painted item fills the whole selected item.
How might I be able to get the icon part of the selected item to fill, just as it does with the text part?
I know TListBox renders like this, but I require the use of TListView for the Data property, also the TListView handles icons better via a TImageList.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用 TListView 的 OnCustomDraw 事件。在事件处理程序中:
有一些方法可以完成这些事情,例如 DrawText 和 FillRect。
请注意,如果您愿意,您可以使用 TListBox 而不是 TListView。您表示您需要列表中项目的 Data 属性,我假设将它们与您的实际模型对象联系起来。您可以使用 TStrings 对支持 TStrings 的任何内容(例如 TListBox.Items)执行此操作。对象。
You'll need to use the OnCustomDraw events of TListView. Within the event handler:
There are methods for doing these things, such as DrawText and FillRect.
Note that you can use TListBox rather than TListView if you'd rather. You indicated you need the Data property for items in the list, I'd assume to tie them up to your actual model objects. You can do this with anything that supports TStrings (such as TListBox.Items) using TStrings.Objects.