Author: Tomas Rutkauskas
I am working on a program that uses a TListView with the checkboxes property set to
true. There are several things I would like to be triggered off of the boxes being
checked or unchecked. Is there any OnCheck event or something similar that I can
use to start a process off of the check of one of these boxes?
Answer:
It seems, there isn't such event. But you could use this workaround:
1 2 procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
3 Shift: TShiftState; X, Y: Integer);
4 var5 li: TListItem;
6 ht: THitTests;
7 begin8 if ListView1.Items.Count <= 0 then9 exit;
10 li := ListView1.GetItemAt(x, y);
11 if Li <> nilthen12 begin13 if li.Selected = false then14 li.Selected := true;
15 end16 else17 exit;
18 ht := LVSoLine.GetHitTestInfoAt(x, y);
19 if ht = [htOnStateIcon] then20 begin21 { Write your code here for checkbox OnCheck event. Remember this will22 fire after the checkbox state is changed }23 end;
24 end;