Reputation: 1188
This is my code:
procedure TfrmMain.vstListPaintText(Sender: TBaseVirtualTree;
const TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
TextType: TVSTTextType);
begin
if vsSelected in Node.States then
begin
TargetCanvas.brush.color := clBlue;
TargetCanvas.FillRect(targetcanvas.ClipRect);
end;
end;
But this is what happens:
How do I avoid #2?
Upvotes: 1
Views: 278
Reputation: 37221
Simple: you're FillRect
-ing the whole canvas. Don't do that. Use OnAfterCellPaint or OnAfterItemPaint. In these events, you get the particular CellRect
to do your custom painting.
Upvotes: 2
Reputation: 419
wrong event if you want to paint the cell - ...PaintText is for setting color and font styles.
Try other events instead (OnBeforeCellPaint) and you will get TRect for the cell automatically.
Upvotes: 4