關於選中節點失去焦點時修改選中節點的方法

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章