如何在虚拟字符串树节点上添加颜色?

时间:2010-08-04 01:16:04

标签: delphi string tree virtual

虚拟字符串树可能看起来像这样吗?

alt text http://sphotos.ak.fbcdn.net/hphotos-ak-ash2/hs142.ash2/40454_1457947221163_1607860397_31141943_5530616_n.jpg

我真的需要帮助,因为我是德尔福的新手。

1 个答案:

答案 0 :(得分:1)

您可以在OnBeforeCellPaint事件中添加一些内容。例如:

procedure TForm1.VirtualStringTree1BeforeCellPaint(Sender: TBaseVirtualTree;      
    TargetCanvas: TCanvas; Node: PVirtualNode;
    Column: TColumnIndex; CellPaintMode: TVTCellPaintMode; CellRect: TRect; 
var     
  ContentRect: TRect);
begin
  CellRect.Left := CellRect.Left + 20;
  TargetCanvas.Brush.Color := clLime;
  TargetCanvas.RoundRect(CellRect, 5, 5);
  InflateRect(ContentRect, -1, -1);
end;

会给你粗略的近似图片中的内容......

N - [