这个你可以重绘节点的背景 代码如下 private void Form1_Load(object sender, EventArgs e)
{
treeView1.HideSelection = false;
treeView1.DrawMode = TreeViewDrawMode.OwnerDrawText;
}
private void treeView1_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
e.Graphics.FillRectangle(Brushes.White, e.Node.Bounds);
if (e.State == TreeNodeStates.Selected)//选中的失去焦点的节点
{
e.Graphics.FillRectangle(Brushes.Black, new Rectangle(e.Node.Bounds.Left - 1, e.Node.Bounds.Top, e.Node.Bounds.Width - 2, e.Node.Bounds.Height)); //黑色背景 e.Graphics.DrawString(e.Node.Text, treeView1.Font, Brushes.White, e.Bounds);//白字 }
else
{
e.DrawDefault = true;
}
}