在虚拟模式的ListView使用复选框 [英] Using checkbox in virtual mode listview
问题描述
我学习,使虚拟模式的ListView。到目前为止,我的问题是,我不能在ListView使用复选框。我已经阅读 HTTP链接://德尔福-kb.blogspot.com/2011/02/draw-checkboxes-in-virtual-mode.html 但我没有看到任何复选框。任何想法?
I am learning to make virtual mode listview. So far my problem is I can not use checkbox in the listview. I already read a link from http://delphi-kb.blogspot.com/2011/02/draw-checkboxes-in-virtual-mode.html but I don't see any checkbox. Any idea?
推荐答案
显然,你要画出自己的复选框,当 OwnerData code>已启用(如链接的文章中提到这个问题)。
Apparently you have to draw the CheckBoxes yourself when OwnerData
is enabled (as mentioned in the article linked in the question).
所以,你必须设置的OwnerDraw
到真
(除了 OwnerData
,两者的 independed 标志!),并自己绘制的复选框中的 OnCustomDrawItem
事件。
So you have to set OwnerDraw
to True
(in addition to OwnerData
, the two are independed flags!) and draw the CheckBoxes yourself in the OnCustomDrawItem
event.
更新:
看来,这是不完全正确,在 OnCustomDrawItem
事件也被触发的情况下的OwnerDraw =假
It seems that this is not entirely true, the OnCustomDrawItem
event is also fired in the case OwnerDraw = False
.
http://docwiki.embarcadero.com/VCL/XE2/ EN / ComCtrls.TListView.OnCustomDrawItem
更新2:
在这个问题联系在一起的code只能在的OwnerDraw =假
和的CheckBox = TRUE
。
The code linked in the question only works when OwnerDraw = False
and CheckBoxes = True
.
否则VCL不保留的剩余空间来绘制的复选框。
Otherwise the VCL doesn't reserve space on the left to draw CheckBoxes.
BTW:你可能会使用类似TVirtualTreeView更先进的组件从麦克蚶更好
BTW: You might be better of using a more advanced component like TVirtualTreeView from Mike Lischke.
这篇关于在虚拟模式的ListView使用复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!