Forum > Packages and Libraries

[SOLVED] TVirtualStringTree checkbox columns - how to make them


I want to draw several TVirtualStringTree columns as check boxes as in attached picture. The picture is actually a TStringGrid where such columns are naturally supported, and no matter how I look I can't find an easy way to do the same into TVirtualStringTree.

I have put an OnPaintText handler like:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TSpotTreeForm.vstSpotsPaintText(Sender: TBaseVirtualTree;  const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;  TextType: TVSTTextType);var  Details: TThemedElementDetails;  R: TRect;begin  if Column = 2 then  begin    R := Sender.GetDisplayRect(Node, Column, False, False, True);    Details := ThemeServices.GetElementDetails(tbCheckBoxCheckedNormal); // or unchecked...    ThemeServices.DrawElement(TargetCanvas.Handle, Details, R, Nil);  end;end;
Surprisingly, It draws the checkbox only when the the mouse pointer is over the cell. Obviously I'm missing something.


Wrong event! It was OnDrawText which needs to be handled, not OnPaintText.


[0] Message Index

Go to full version