TreeView Class Key Points

TreeView keep selected node highlighted

public QualityCheck()
        {
            InitializeComponent();

            //trvIndexName.HideSelection = false;
            //trvIndexName.SelectedNode.BackColor = Color.BlueViolet;  // cause DLL problem

            trvIndexName.DrawMode = TreeViewDrawMode.OwnerDrawAll;
            trvIndexName.DrawNode += new DrawTreeNodeEventHandler(trvIndexName_DrawNode);

        }

        void trvIndexName_DrawNode(object sender, DrawTreeNodeEventArgs e)
        {
            ) && (!trvIndexName.Focused))
                e.Node.ForeColor = Color.Blue;
            else
                e.DrawDefault = true;
        }

        private void trvIndexName_BeforeSelect(object sender, TreeViewCancelEventArgs e)
        {
            if (trvIndexName.SelectedNode != null)
                trvIndexName.SelectedNode.ForeColor = Color.Black;
            e.Node.ForeColor = Color.Blue;
        }
上一篇:Core Animation 文档翻译 (第七篇)——改变Layer的默认动画


下一篇:Core Animation 文档翻译 (第八篇)—提高动画的性能