在虚拟模式列表视图中使用复选框
我正在学习制作虚拟模式列表视图。到目前为止,我的问题是我无法在列表视图中使用复选框。我已经阅读了 http://delphi 的链接-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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,当启用
OwnerData
时,您必须自己绘制复选框(如问题中链接的文章中所述)。因此,您必须将
OwnerDraw
设置为True
(除了OwnerData
之外,这两个是独立标志!)并且在OnCustomDrawItem
事件中自行绘制复选框。更新:
这似乎并不完全正确,在
OwnerDraw = False
的情况下也会触发OnCustomDrawItem
事件。http://docwiki.embarcadero.com/VCL/XE2/en/ComCtrls .TListView.OnCustomDrawItem
更新 2:
问题中链接的代码仅在
OwnerDraw = False
和CheckBoxes = True
。否则,VCL 不会在左侧保留空间来绘制复选框。
顺便说一句:您可能最好使用更高级的组件,例如 Mike Lischke 的 TVirtualTreeView。
Apparently you have to draw the CheckBoxes yourself when
OwnerData
is enabled (as mentioned in the article linked in the question).So you have to set
OwnerDraw
toTrue
(in addition toOwnerData
, the two are independed flags!) and draw the CheckBoxes yourself in theOnCustomDrawItem
event.Update:
It seems that this is not entirely true, the
OnCustomDrawItem
event is also fired in the caseOwnerDraw = False
.http://docwiki.embarcadero.com/VCL/XE2/en/ComCtrls.TListView.OnCustomDrawItem
Update 2:
The code linked in the question only works when
OwnerDraw = False
andCheckBoxes = True
.Otherwise the VCL doesn't reserve space on the left to draw CheckBoxes.
BTW: You might be better of using a more advanced component like TVirtualTreeView from Mike Lischke.