Simulate an OnCheck event for TListView checkboxes (Views: 100)


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?


It seems, there isn't such event. But you could use this workaround:

procedure TForm1.ListView1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
  li: TListItem;
  ht: THitTests;
  if ListView1.Items.Count <= 0 then
  li := ListView1.GetItemAt(x, y);
  if Li <> nil then
    if li.Selected = false then
      li.Selected := true;
  ht := LVSoLine.GetHitTestInfoAt(x, y);
  if ht = [htOnStateIcon] then
    { Write your code here for checkbox OnCheck event. Remember this will
    fire after the checkbox state is changed }

<< Back to main page