Treeview 丟失焦點後依然高亮 SelectedNode
阿新 • • 發佈:2017-08-05
start eight val selected void send splay TreeView relative
參考:StackOverFlow、Control.Validating 事件
註意 TreeView 的 HideSelection 要保持為默認值True
。
private TreeNode previousSelectedNode; private void treeView1_Validating(object sender, System.ComponentModel.CancelEventArgs e) { treeView1.SelectedNode.BackColor = SystemColors.Highlight; treeView1.SelectedNode.ForeColor = Color.White; previousSelectedNode = treeView1.SelectedNode; }private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if(previousSelectedNode != null) { previousSelectedNode.BackColor = treeView1.BackColor; previousSelectedNode.ForeColor = treeView1.ForeColor; } }
Treeview 丟失焦點後依然高亮 SelectedNode