The TVirtualStringTree uses a rather different set of procedures for painting the cells of the tree. If you look in the help you will find that there are several events occuring for each cell. The ones you probably are interested in are:
OnBeforeCellPaint
OnPaintText
OnDrawText
OnBeforeCellPaint()
provides the CellRect
parameter, which you can use to fill the whole background, including tree expand symbol and eventual node image, or, using ContentRect
, excluding tree expand symbol space,
procedure TForm1.VSTBeforeCellPaint(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
and then use OnPaintText()
to draw the text
procedure TForm1.VSTPaintText(Sender: TBaseVirtualTree;
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType);
Alternatively, maybe easier to use only OnDrawText()
in which you can both fill the text background (but, excluding tree expand symbol and image) and draw the text
procedure TForm1.VSTDrawText(Sender: TBaseVirtualTree; TargetCanvas: TCanvas;
Node: PVirtualNode; Column: TColumnIndex; const Text: string;
const CellRect: TRect; var DefaultDraw: Boolean);
Btw, I recommend looking at the help file in the dl package, for further details regarding painting the tree. The chapter Paint Cycles and Stages starts with this: The most complex process in Virtual Treeview is without doubts its painting. Read here what stages Virtual Treeview enters during paint and how you can customize this process.