4

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

TLama
  • 75,147
  • 17
  • 214
  • 392
Thiago Dias
  • 121
  • 6
  • 2
    In `OnColumnsHeaderClick` you can test `if (hhiOnCheckbox in HitInfo.HitPosition) then`. – TLama Mar 11 '15 at 16:51
  • 1
    @TLama You mean 'OnHeaderClick' I think. And it works perfectly! Thanks! – Thiago Dias Mar 11 '15 at 17:02
  • D'oh. Sure, it's `OnHeaderClick`. I've copied a part of a method name from a real application (where VT was related to export columns, hence that extra `Columns` in the name). – TLama Mar 11 '15 at 17:05
  • And now, how can I get the state of this header checkbox? I tried a lot and could not find a way to do that. – Thiago Dias Mar 16 '15 at 11:33

1 Answers1

4

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;
TLama
  • 75,147
  • 17
  • 214
  • 392