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