Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using checkbox in virtual mode listview

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?

like image 430
Charles Sungkono Avatar asked Jun 12 '26 00:06

Charles Sungkono


1 Answers

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 to True (in addition to OwnerData, the two are independed flags!) and draw the CheckBoxes yourself in the OnCustomDrawItem event.

Update:

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

Update 2:

The code linked in the question only works when OwnerDraw = False and CheckBoxes = 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.

like image 176
Jens Mühlenhoff Avatar answered Jun 13 '26 23:06

Jens Mühlenhoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!