开发者

change treeview node color

Is the开发者_JAVA百科re 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 http://rigo.ro/temp/ChangeTreeViewNodeColor.png


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;


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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜