Try this
You have to Change the
DrawMode
from
Normal
to
OwnerDrawText
and Change the color in
drawNode
event
private void Form1_Load(object sender, EventArgs e)
{
treeView1.DrawMode = TreeViewDrawMode.OwnerDrawText;
}
SolidBrush greenBrush = new SolidBrush(Color.Green);
private void treeView1_drawNode(object sender, DrawTreeNodeEventArgs e)
{
if (e.Node.IsSelected)
{
if (treeView1.Focused)
e.Graphics.FillRectangle(greenBrush, e.Bounds);
}
else
e.Graphics.FillRectangle(Brushes.White, e.Bounds);
TextRenderer.DrawText(e.Graphics, e.Node.Text, e.Node.TreeView.Font, e.Node.Bounds, e.Node.ForeColor);
}