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) { if (((e.State & TreeNodeStates.Selected) != 0) && (!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; }
TreeView Class Kek Points
时间: 2024-11-29 05:41:20