views:

82

answers:

1

I want to change the color of text in a specific row of a virtual string tree. is it possible?

+2  A: 

Use the OnBeforeCellPaint event:

procedure TForm1.VirtualStringTree1BeforeCellPaint(Sender: TBaseVirtualTree;
  TargetCanvas: TCanvas; Node: PVirtualNode; Column: TColumnIndex;
  CellPaintMode: TVTCellPaintMode; CellRect: TRect; var ContentRect: TRect);
begin
  if Node.Index mod 2 = 0 then
  begin
    TargetCanvas.Brush.Color := clFuchsia;
    TargetCanvas.FillRect(CellRect);
  end;
end;

This will change the background on every other row (if the rows are on the same level).

Nat