Reputation:
In my project i have to set fore color for Treeview node as blue which node have children nodes that nodes only in blue color,remaining nodes are having default color,Here my doubt is in which event i write the code for setting the fore color for treeview nodes.
regards Krishna
Upvotes: 1
Views: 9636
Reputation:
TreeView.Node has a ForeColor and a BackColor property, is that what you are looking for? Something like this:
TreeView tv = new TreeView();
tv.Nodes.Add("node1", "Node 1");
tv.Nodes.Add("node2", "Node 2");
tv.Nodes["node1"].ForeColor = System.Drawing.Color.Blue;
tv.Nodes["node2"].ForeColor = System.Drawing.Color.Black;
To check for child nodes of a particular node:
node.ForeColor = node.Nodes.Count > 0
? System.Drawing.Color.Blue
: System.Drawing.Color.Black;
Upvotes: 2