Search code examples
delphivirtualtreeviewtvirtualstringtree

How to get notified when the user clicks the header column check box in VirtualTreeView control?


Is there an event notifying about the VirtualTreeView header column check box click? It is the check box highlighted on this picture:

enter image description here


Solution

  • Write a handler for the OnHeaderClick event and check if the HitPosition property of the HitInfo parameter contains the hhiOnCheckbox flag. For example:

    procedure TForm1.VirtualTreeHeaderClick(Sender: TVTHeader; HitInfo: TVTHeaderHitInfo);
    begin
      if hhiOnCheckbox in HitInfo.HitPosition then
      begin
        if Sender.Columns[HitInfo.Column].CheckState = csCheckedNormal then
          ShowMessage('Checked!')
        else
          ShowMessage('Unchecked!')
      end;
    end;