#region 更改失去焦點選中節點的顏色
private void Tree_Organize_DrawNode(object sender, DrawTreeNodeEventArgs e)
{
e.Graphics.FillRectangle(Brushes.White, e.Node.Bounds);
if (e.State == TreeNodeStates.Selected)//選中的失去焦點的節點
{
e.Graphics.FillRectangle(Brushes.Gray, 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, Tree_Organize.Font, Brushes.White,e.Bounds.Location.X,e.Bounds.Location.Y);//字體
}
else
{
e.DrawDefault = true;
}
}
#endregion
在窗體的LODE事件中加上:
Tree_Organize.HideSelection = false;
Tree_Organize.DrawMode = TreeViewDrawMode.OwnerDrawText;