Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change the color of a row in a virtual string tree?

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

like image 314
jhodzzz Avatar asked Jul 23 '10 01:07

jhodzzz


1 Answers

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).

like image 134
Nat Avatar answered Nov 01 '22 05:11

Nat