views:

872

answers:

2

Hi all

Is there any way to change the color of the nodes in a TTreeView. I want to color my treeview with a dark color and then I can't see the nodes.

alt text

+1  A: 

maybe you can use OnCustomDrawItem event of TTreeView:

procedure TForm1.TreeView1CustomDrawItem(Sender: TCustomTreeView;
  Node: TTreeNode; State: TCustomDrawState; var DefaultDraw: Boolean);
begin
  with Sender as TCustomTreeView do
  begin
    Canvas.Brush.Color := clBlack;
    Canvas.Font.Color := clBlack
  end;
end;
SimaWB
What will this accomplish ? This will draw the items with black foreground and black background. Remus is asking about painting only the tree lines, no ?
Edelcom
yes, that is true, i want to change only the color of the tree lines
Remus Rigo
+3  A: 

It is not easily evident that you only wanted to change the line color. Anyway, there's a message for that in the API;

uses
  commctrl;

procedure TForm1.FormCreate(Sender: TObject);
begin
  SendMessage(TreeView1.Handle, TVM_SETLINECOLOR, 0, ColorToRGB(clYellow));
end;
Sertac Akyuz